예제 #1
0
void WxWindow::setCursorVisiblePriority(bool state, int32 priority)
{
	if(cursorPriority > priority)
		return;

	setCursorVisible(state);
	
	if( !state )
		cursorPriority = 0;
}
예제 #2
0
///////////////////////运行函数
void initSnake()
{
	int i;
	for (i = 0; i < SNAKE_MIN_LEN; i++)
	{
		mySnake[i].x = 10 - i;
		mySnake[i].y = 3;//////(10,3)坐标可任意摆放
	}
	fixConsoleSize((TOTAL_WIDTH) * 2, TOTAL_HEIGHT);
	setCursorVisible(0);
	setConsoleTitle("Snake");
}
예제 #3
0
void QLineEditPrivate::_q_selectionChanged()
{
    Q_Q(QLineEdit);
    if (!control->text().isEmpty() && control->preeditAreaText().isEmpty()) {
        QStyleOptionFrameV2 opt;
        q->initStyleOption(&opt);
        bool showCursor = control->hasSelectedText() ?
                          q->style()->styleHint(QStyle::SH_BlinkCursorWhenTextSelected, &opt, q):
                          q->hasFocus();
        setCursorVisible(showCursor);
    }

    emit q->selectionChanged();
}
예제 #4
0
파일: qlineedit_p.cpp 프로젝트: Suneal/qt
void QLineEditPrivate::_q_selectionChanged()
{
    Q_Q(QLineEdit);
    if (control->preeditAreaText().isEmpty()) {
        QStyleOptionFrameV2 opt;
        q->initStyleOption(&opt);
        bool showCursor = control->hasSelectedText() ?
                          q->style()->styleHint(QStyle::SH_BlinkCursorWhenTextSelected, &opt, q):
                          q->hasFocus();
        setCursorVisible(showCursor);
    }

    emit q->selectionChanged();
#ifndef QT_NO_ACCESSIBILITY
    QAccessible::updateAccessibility(q, 0, QAccessible::TextSelectionChanged);
#endif
}
예제 #5
0
void UITextEdit::onStyleApply(const std::string& styleName, const OTMLNodePtr& styleNode)
{
    UIWidget::onStyleApply(styleName, styleNode);

    for(const OTMLNodePtr& node : styleNode->children()) {
        if(node->tag() == "text") {
            setText(node->value());
            setCursorPos(m_text.length());
        } else if(node->tag() == "text-hidden")
            setTextHidden(node->value<bool>());
        else if(node->tag() == "shift-navigation")
            setShiftNavigation(node->value<bool>());
        else if(node->tag() == "multiline")
            setMultiline(node->value<bool>());
        else if(node->tag() == "max-length")
            setMaxLength(node->value<int>());
        else if(node->tag() == "editable")
            setEditable(node->value<bool>());
        else if(node->tag() == "selectable")
            setSelectable(node->value<bool>());
        else if(node->tag() == "selection-color")
            setSelectionColor(node->value<Color>());
        else if(node->tag() == "selection-background-color")
            setSelectionBackgroundColor(node->value<Color>());
        else if(node->tag() == "selection") {
            Point selectionRange = node->value<Point>();
            setSelection(selectionRange.x, selectionRange.y);
        }
        else if(node->tag() == "cursor-visible")
            setCursorVisible(node->value<bool>());
        else if(node->tag() == "change-cursor-image")
            setChangeCursorImage(node->value<bool>());
        else if(node->tag() == "auto-scroll")
            setAutoScroll(node->value<bool>());
    }
}
예제 #6
0
bool ComposerEngine::tickOldScript(OldScript *script) {
	if (script->_currDelay) {
		script->_currDelay--;
		return true;
	}

	bool running = true;
	bool erasedOldSprite = false;
	while (running && script->_stream->pos() < (int)script->_size) {
		uint16 spriteId, scriptId, buttonId, pipeId;
		Common::Point spritePos;

		script->_stream->skip(0);
		byte op = script->_stream->readByte();
		switch (op) {
		case kOldOpNoOp:
			debug(3, "kOldOpNoOp()");
			running = false;
			break;
		case kOldOpReplaceSprite:
			if (!erasedOldSprite) {
				removeSprite(0, script->_id);
				erasedOldSprite = true;
			}

			spriteId = script->_stream->readUint16LE();
			spritePos.x = script->_stream->readSint16LE();
			spritePos.y = script->_stream->readSint16LE();
			debug(3, "kOldOpReplaceSprite(%d, %d, %d)", spriteId, spritePos.x, spritePos.y);
			addSprite(spriteId, script->_id, script->_zorder, spritePos);
			break;
		case kOldOpPlayWav:
			uint16 wavId, prio;
			wavId = script->_stream->readUint16LE();
			prio = script->_stream->readUint16LE();
			debug(3, "kOldOpPlayWav(%d, %d)", wavId, prio);
			playWaveForAnim(wavId, prio, false);
			break;
		case kOldOpRunScript:
			scriptId = script->_stream->readUint16LE();
			debug(3, "kOldOpRunScript(%d)", scriptId);
			if (scriptId == script->_id) {
				// reset ourselves
				removeSprite(0, script->_id);
				script->_stream->seek(6);
			} else {
				runScript(scriptId);
			}
			break;
		case kOldOpStopScript:
			scriptId = script->_stream->readUint16LE();
			debug(3, "kOldOpStopScript(%d)", scriptId);
			removeSprite(0, scriptId);
			stopOldScript(scriptId);
			break;
		case kOldOpActivateButton:
			buttonId = script->_stream->readUint16LE();
			debug(3, "kOldOpActivateButton(%d)", buttonId);
			setButtonActive(buttonId, true);
			break;
		case kOldOpDeactivateButton:
			buttonId = script->_stream->readUint16LE();
			debug(3, "kOldOpDeactivateButton(%d)", buttonId);
			setButtonActive(buttonId, false);
			break;
		case kOldOpDrawSprite:
			spriteId = script->_stream->readUint16LE();
			spritePos.x = script->_stream->readSint16LE();
			spritePos.y = script->_stream->readSint16LE();
			debug(3, "kOldOpDrawSprite(%d, %d, %d)", spriteId, spritePos.x, spritePos.y);
			addSprite(spriteId, script->_id, script->_zorder, spritePos);
			break;
		case kOldOpRemoveSprite:
			spriteId = script->_stream->readUint16LE();
			debug(3, "kOldOpRemoveSprite(%d)", spriteId);
			removeSprite(spriteId, script->_id);
			break;
		case kOldOpDisableMouseInput:
			debug(3, "kOldOpDisableMouseInput()");
			setCursorVisible(false);
			break;
		case kOldOpEnableMouseInput:
			debug(3, "kOldOpEnableMouseInput()");
			setCursorVisible(true);
			break;
		case kOldOpWait:
			script->_currDelay = script->_stream->readUint16LE();
			debug(3, "kOldOpWait(%d)", script->_currDelay);
			break;
		case kOldOpRandWait:
			uint16 min, max;
			min = script->_stream->readUint16LE();
			max = script->_stream->readUint16LE();
			debug(3, "kOldOpRandWait(%d, %d)", min, max);
			script->_currDelay = _rnd->getRandomNumberRng(min, max);
			break;
		case kOldOpDrawGlobalSprite:
			spriteId = script->_stream->readUint16LE();
			spritePos.x = script->_stream->readSint16LE();
			spritePos.y = script->_stream->readSint16LE();
			debug(3, "kOldOpDrawGlobalSprite(%d, %d, %d)", spriteId, spritePos.x, spritePos.y);
			addSprite(spriteId, 0, script->_zorder, spritePos);
			break;
		case kOldOpRemoveGlobalSprite:
			spriteId = script->_stream->readUint16LE();
			debug(3, "kOldOpRemoveGlobalSprite(%d)", spriteId);
			removeSprite(spriteId, 0);
			break;
		case kOldOpSetZOrder:
			script->_zorder = script->_stream->readUint16LE();
			debug(3, "kOldOpSetZOrder(%d)", script->_zorder);
			break;
		case kOldOpPlayPipe:
			pipeId = script->_stream->readUint16LE();
			debug(3, "kOldOpPlayPipe(%d)", pipeId);
			playPipe(pipeId);
			break;
		case kOldOpStopPipe:
			pipeId = script->_stream->readUint16LE();
			debug(3, "kOldOpStopPipe(%d)", pipeId);
			// yes, pipeId is ignored here..
			stopPipes();
			break;
		case kOldOpNewScreen:
			uint16 newScreenId;
			newScreenId = script->_stream->readUint16LE();
			debug(3, "kOldOpNewScreen(%d)", newScreenId);
			if (!newScreenId) {
				quitGame();
			} else {
				_pendingPageChanges.clear();
				_pendingPageChanges.push_back(PendingPageChange(newScreenId, false));
			}
			break;
		case kOldOpRunRandom:
			uint16 randomId;
			randomId = script->_stream->readUint16LE();
			debug(3, "kOldOpRunRandom(%d)", randomId);
			if (!_randomEvents.contains(randomId)) {
				warning("kOldOpRunRandom found no entries for id %d", randomId);
			} else {
				uint32 randValue = _rnd->getRandomNumberRng(0, 32767);
				const Common::Array<RandomEvent> &events = _randomEvents[randomId];
				uint i = 0;
				for (i = 0; i < events.size(); i++) {
					if ((i + 1 == events.size()) || (randValue <= events[i].weight)) {
						runScript(events[i].scriptId);
						break;
					} else {
						randValue -= events[i].weight;
					}
				}
			}
			break;
		default:
			error("unknown oldScript op %d", op);
		}
	}

	if (script->_stream->pos() >= (int)script->_size) {
		// stop running if we ran out of script
		removeSprite(0, script->_id);
		return false;
	}

	return true;
}
예제 #7
0
//主函数
int main()
{ clock_t start,finish;
   int isPause = 1;
   int chance=0;
   float RewardTime=0;
   int z;
   
   setCursorVisible(0);
   setConsoleTitle("贪吃蛇--D_Y。 2010.1.11");        //标题
   ch=menu();
   ch2=menuDouble();               
   if(ch2=='1')
    z=0;
   if(ch2=='2')
    z=1;
   initSnake(SNAKE_MIN_LEN,z);
   drawMap();
   drawSnake(z);
   //PlaySound("d:\\泡泡堂轻松欢快音乐音效WAV.wav",NULL, SND_ASYNC|SND_NODEFAULT|SND_LOOP );   
   switch(ch)                 //不同的难度对应不同的奖励食物消失时间
   {
   case '1':
       RewardTime=2500;
   case '2':
    RewardTime=3000;
   case '3':
    RewardTime=3500;
   }
   while (!isOver[0]&&!isOver[1])             //当两条蛇任意一条死亡则游戏结束
   {   
    srand((uint32)time(NULL));
      if (!isPause)                           
      {
         moveSnake(z);
         if (!isFood)
            drawFood();
    while(((point[1]+point[0])%4==0)&&((point[1]+point[0])>3)&&p==1)        
                                                          //规定在得分大于三分时每吃掉四个常规食物产生一个奖励食物
    { 
     if (!isReward)
    drawReward();
       start=clock();                                        //画出食物,记录此刻时间
      break;  
    }

    finish=start+RewardTime ;                                //结束时间为开始时间加规定的奖励食物出现时间
            if((isReward==1)&&(finish<=clock()))
    {
             drawBlock(myReward.x, myReward.y, BS_SPACE); //超出规定时间则将奖励食物用背景方框覆盖
    myReward.x=-1;
    myReward.y=-1;
    isReward=0;                                           
    }
    if(((point[1]+point[0])%3==0)&&((point[1]+point[0])>2)&&q==0)                         
    {
    
      clearBar();
    
                    drawBar();
    }
           
    setTextColor(myColors[4]);                                    //规定出输出分数等信息
    gotoTextPos(MAP_BASE_X*2 -14 , MAP_BASE_Y + 2);
    printf("Player 1");
   gotoTextPos(MAP_BASE_X*2 -14 , MAP_BASE_Y + 4);
   
            printf("Score: %d.", point[0]);
    if(z==1)
    {
   gotoTextPos(MAP_BASE_X*2 + MAP_WIDTH*2+4 , MAP_BASE_Y + 2);
            printf("Player 2");
   gotoTextPos(MAP_BASE_X*2 + MAP_WIDTH*2+4 , MAP_BASE_Y + 4);
            printf("Score: %d.", point[1]);
    }                                                          
   
    
      }
      DELAY(ch); //赋予游戏速度
   delayMS(80- snakeLength[0]*2); //游戏速度随着蛇身增长而增加
      if (jkHasKey()) //键盘控制
      {
         switch (jkGetKey())
         {
      
            case JK_UP:
               if (snakeDir[0] != DIR_DOWN)
                  snakeDir[0] = DIR_UP;
      break;
    case 'w': 
               if (snakeDir[1] != DIR_DOWN)
                  snakeDir[1] = DIR_UP;
               
               break;
  
            case JK_DOWN:
               if (snakeDir[0] != DIR_UP)
                  snakeDir[0] = DIR_DOWN;
      break;
      case 's': 
      if (snakeDir[1] != DIR_UP)
                  snakeDir[1] = DIR_DOWN;
               break;
  
            case JK_LEFT:
               if (snakeDir[0] != DIR_RIGHT)
                  snakeDir[0] = DIR_LEFT;
      break;
      case 'a': 
       if (snakeDir[1] != DIR_RIGHT)
                  snakeDir[1] = DIR_LEFT;
               break;
  
            case JK_RIGHT:
               if (snakeDir[0] != DIR_LEFT)
                  snakeDir[0] = DIR_RIGHT;
      case 'd': 
        if (snakeDir[1] != DIR_LEFT)
                  snakeDir[1] = DIR_RIGHT;
               break;
            case JK_ENTER:
            case JK_SPACE:
               isPause = !isPause;
               break;
      case JK_ESC:
       isOver[0]=1;
       break;
            default:
               break;
         }

      }
   }
   PlaySound("d:\\超级马里奥兄弟 死掉音.wav",NULL, SND_ASYNC|SND_NODEFAULT );
   gotoTextPos(MAP_BASE_X + MAP_WIDTH - 7, MAP_BASE_Y + MAP_HEIGHT + 1);
   if(isOver[0]==1&&z==0)
printf("Game Over!!");
   if(isOver[0]==1&&z==1)
printf("Player 2 win!!");   
   if(isOver[1]==1)
   printf("Player 1 win!!");//游戏结束,在规定处显示分数
   getch();
   return 0;
}
예제 #8
0
int QDeclarativeTextEdit::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QDeclarativeImplicitSizePaintedItem::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        if (_id < 47)
            qt_static_metacall(this, _c, _id, _a);
        _id -= 47;
    }
#ifndef QT_NO_PROPERTIES
      else if (_c == QMetaObject::ReadProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: *reinterpret_cast< QString*>(_v) = text(); break;
        case 1: *reinterpret_cast< QColor*>(_v) = color(); break;
        case 2: *reinterpret_cast< QColor*>(_v) = selectionColor(); break;
        case 3: *reinterpret_cast< QColor*>(_v) = selectedTextColor(); break;
        case 4: *reinterpret_cast< QFont*>(_v) = font(); break;
        case 5: *reinterpret_cast< HAlignment*>(_v) = hAlign(); break;
        case 6: *reinterpret_cast< VAlignment*>(_v) = vAlign(); break;
        case 7: *reinterpret_cast< WrapMode*>(_v) = wrapMode(); break;
        case 8: *reinterpret_cast< int*>(_v) = lineCount(); break;
        case 9: *reinterpret_cast< qreal*>(_v) = paintedWidth(); break;
        case 10: *reinterpret_cast< qreal*>(_v) = paintedHeight(); break;
        case 11: *reinterpret_cast< TextFormat*>(_v) = textFormat(); break;
        case 12: *reinterpret_cast< bool*>(_v) = isReadOnly(); break;
        case 13: *reinterpret_cast< bool*>(_v) = isCursorVisible(); break;
        case 14: *reinterpret_cast< int*>(_v) = cursorPosition(); break;
        case 15: *reinterpret_cast< QRect*>(_v) = cursorRectangle(); break;
        case 16: *reinterpret_cast< QDeclarativeComponent**>(_v) = cursorDelegate(); break;
        case 17: *reinterpret_cast< int*>(_v) = selectionStart(); break;
        case 18: *reinterpret_cast< int*>(_v) = selectionEnd(); break;
        case 19: *reinterpret_cast< QString*>(_v) = selectedText(); break;
        case 20: *reinterpret_cast< bool*>(_v) = focusOnPress(); break;
        case 21: *reinterpret_cast< bool*>(_v) = persistentSelection(); break;
        case 22: *reinterpret_cast< qreal*>(_v) = textMargin(); break;
        case 23: *reinterpret_cast< Qt::InputMethodHints*>(_v) = inputMethodHints(); break;
        case 24: *reinterpret_cast< bool*>(_v) = selectByMouse(); break;
        case 25: *reinterpret_cast< SelectionMode*>(_v) = mouseSelectionMode(); break;
        case 26: *reinterpret_cast< bool*>(_v) = canPaste(); break;
        case 27: *reinterpret_cast< bool*>(_v) = isInputMethodComposing(); break;
        }
        _id -= 28;
    } else if (_c == QMetaObject::WriteProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: setText(*reinterpret_cast< QString*>(_v)); break;
        case 1: setColor(*reinterpret_cast< QColor*>(_v)); break;
        case 2: setSelectionColor(*reinterpret_cast< QColor*>(_v)); break;
        case 3: setSelectedTextColor(*reinterpret_cast< QColor*>(_v)); break;
        case 4: setFont(*reinterpret_cast< QFont*>(_v)); break;
        case 5: setHAlign(*reinterpret_cast< HAlignment*>(_v)); break;
        case 6: setVAlign(*reinterpret_cast< VAlignment*>(_v)); break;
        case 7: setWrapMode(*reinterpret_cast< WrapMode*>(_v)); break;
        case 11: setTextFormat(*reinterpret_cast< TextFormat*>(_v)); break;
        case 12: setReadOnly(*reinterpret_cast< bool*>(_v)); break;
        case 13: setCursorVisible(*reinterpret_cast< bool*>(_v)); break;
        case 14: setCursorPosition(*reinterpret_cast< int*>(_v)); break;
        case 16: setCursorDelegate(*reinterpret_cast< QDeclarativeComponent**>(_v)); break;
        case 20: setFocusOnPress(*reinterpret_cast< bool*>(_v)); break;
        case 21: setPersistentSelection(*reinterpret_cast< bool*>(_v)); break;
        case 22: setTextMargin(*reinterpret_cast< qreal*>(_v)); break;
        case 23: setInputMethodHints(*reinterpret_cast< Qt::InputMethodHints*>(_v)); break;
        case 24: setSelectByMouse(*reinterpret_cast< bool*>(_v)); break;
        case 25: setMouseSelectionMode(*reinterpret_cast< SelectionMode*>(_v)); break;
        }
        _id -= 28;
    } else if (_c == QMetaObject::ResetProperty) {
        switch (_id) {
        case 5: resetHAlign(); break;
        }
        _id -= 28;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 28;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 28;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 28;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 28;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 28;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}