Esempio n. 1
0
void DictFilterConfig::doMenu(const QAction * i)
{
    if (i == addA) {
        if ( input.count() == 0 ) {
            QMessageBox::information(0, tr("Adding Words"),
                tr("<qt>To add words, pick the letters, then "
                "open the Add dialog. In that dialog, tap "
                "the correct letters from the list "
                "(tap twice for capitals).</qt>"));
        } else {
            PickboardAdd add(parent,capitalize(input));
            if ( add.exec() )
                generateText(add.word());
            input.clear();
            matches.clear();
            updateRows(0,0);
        }
    } else if (i == resetA) {
        if ( !input.isEmpty() ) {
            input.clear();
            matches.clear();
            StringConfig::doMenu(i);
            updateRows(0,1);
        } else {
            reset();
        }
    } else {
        StringConfig::doMenu(i);
    }
    shift = 0;
    lit0 = -1;
}
Esempio n. 2
0
void Game::handleInput(sf::Event e) {
	sf::Vector2f direction(0, 0);
	if (e.key.code == sf::Keyboard::Escape)
		isRunning = false;

	string key;
	if (e.type == sf::Event::KeyPressed) {
		switch (e.key.code) {
		case sf::Keyboard::Up:
			direction += sf::Vector2f(0, -1);
			break;
		case sf::Keyboard::Down:
			direction += sf::Vector2f(0, 1);
			break;
		case sf::Keyboard::Left:
			direction += sf::Vector2f(-1, 0);
			break;
		case sf::Keyboard::Right:
			direction += sf::Vector2f(1, 0);
			break;
		}
		generateText(direction);
	}
	m_direction += direction;
}
Esempio n. 3
0
void DictFilterConfig::pick(bool press, int row, int item)
{
    if ( row == 0 ) {
        if ( press ) {
            if ( input.isEmpty() ) {
                lit0 = item;
                if ( othermodes[item] == PickboardPicks::tr("Space") ) {
                    updateItem(row,item);
                    qwsServer->sendKeyEvent( ' ', Qt::Key_Space, 0, true, false );
                    qwsServer->sendKeyEvent( ' ', Qt::Key_Space, 0, false, false );
                } else if ( othermodes[item] == PickboardPicks::tr("Back") ) {
                    updateItem(row,item);
                    qwsServer->sendKeyEvent( 8, Qt::Key_Backspace, 0, true, false );
                    qwsServer->sendKeyEvent( 8, Qt::Key_Backspace, 0, false, false );
                } else if ( othermodes[item] == PickboardPicks::tr("Enter") ) {
                    updateItem(row,item);
                    qwsServer->sendKeyEvent( 8, Qt::Key_Backspace, 0, true, false );
                    qwsServer->sendKeyEvent( 8, Qt::Key_Backspace, 0, false, false );
                } else if ( othermodes[item] == PickboardPicks::tr("Shift") ) {
                    updateItem(row,item);
                    shift = (shift+1)%3;
                }
            }
        } else {
            if ( !input.isEmpty() ) {
                input.clear();
                if ( item>=0 ) {
                    generateText(capitalize(matches[item]));
                }
                shift = 0;
                matches.clear();
                updateRows(0,0);
            } else if ( item < 3 ) {
                lit0 = -1;
                changeMode(item+1); // I'm mode 0! ####
                updateRows(0,1);
            }
            if ( lit0 >= 0 ) {
                if ( !shift || othermodes[lit0] != PickboardPicks::tr("Shift") ) {
                    updateItem(0,lit0);
                    lit0 = -1;
                }
            }
        }
    } else {
        lit0 = -1;
        if ( press && item >= 0 ) {
            lit1 = item;
            add(sets[item]);
            updateItem(1,item);
            updateRows(0,0);
        } else {
            updateItem(1,lit1);
            lit1 = -1;
        }
    }
}
Esempio n. 4
0
void CharConfig::pick(bool press, int row, int item)
{
    if ( !press ) {
        if ( item >= 0 ) {
            generateText(row == 0 ? chars1[item] : chars2[item]);
        }
        changeMode(0);
        updateRows(0,1);
    }
}
Esempio n. 5
0
void CharStringConfig::pick(bool press, int row, int item)
{
    if ( row == 0 ) {
        if ( !press ) {
            if ( item>=0 ) {
                generateText(input);
            }
            input = "";
            changeMode(0);
            updateRows(0,1);
        }
    } else {
        if ( press && item >= 0 ) {
            input.append(chars[item]);
            updateRows(0,0);
        }
    }
}
Esempio n. 6
0
void ofxSlider<Type>::generateDraw(){
    
	bg.clear();
	bar.clear();

	bg.setFillColor(thisBackgroundColor);
	bg.setFilled(true);
	bg.rectangle(b);
    
	float valAsPct = ofMap( value, value.getMin(), value.getMax(), 0, b.width-2, true );
	bar.setFillColor(thisFillColor);
	bar.setFilled(true);
	bar.rectangle(b.x+1, b.y+1, valAsPct, b.height-2);

	generateText();
    
    requiresRerender = true;
}
Esempio n. 7
0
void init() {
	g_stateManager = new StateManager();
	
	TTF_Font* font = TTF_OpenFont("./fonts/station.ttf", 46);
	SDL_Color fontColor = {0, 0, 0};
	
	// Options menu
	GameMenu* optionsMenu = new GameMenu(loadTexture("./img/menubackground.png"), 4, 2);
	
	MenuButton* controlsButton = new MenuButton(loadTexture("./img/button_style_A.png"), generateText(font, "CONTROLS", fontColor), NULL);
	MenuButton* gamplayButton = new MenuButton(loadTexture("./img/button_style_A.png"), generateText(font, "GAMEPLAY", fontColor), NULL);
	MenuButton* audioButton = new MenuButton(loadTexture("./img/button_style_A.png"), generateText(font, "AUDIO", fontColor), NULL);
	MenuButton* graphicsButton = new MenuButton(loadTexture("./img/button_style_A.png"), generateText(font, "GRAPHICS", fontColor), NULL);
	MenuButton* backButton = new MenuButton(loadTexture("./img/button_style_A.png"), generateText(font, "BACK", fontColor), NULL);
	
	optionsMenu->addMenuOption(controlsButton, 0, 1);
	optionsMenu->addMenuOption(gamplayButton, 1, 1);
	optionsMenu->addMenuOption(audioButton, 0, 2);
	optionsMenu->addMenuOption(graphicsButton, 1, 2);
	optionsMenu->addMenuOption(backButton, 1, 3);
	
	MenuState* optionsMenuState = new MenuState(loadTexture("./img/back.jpg"), optionsMenu);
	
	// Main menu
	GameMenu* startMenu = new GameMenu(loadTexture("./img/menubackground.png"), 4, 1);
	
	MenuButton* startButton = new MenuButton(loadTexture("./img/button_style_A.png"), generateText(font, "START", fontColor), NULL);
	MenuButton* optionsButton = new MenuButton(loadTexture("./img/button_style_A.png"), generateText(font, "OPTIONS", fontColor), optionsMenuState);
	MenuButton* exitButton = new MenuButton(loadTexture("./img/button_style_A.png"), generateText(font, "EXIT", fontColor), NULL);
	
	startMenu->addMenuOption(startButton, 0, 1);
	startMenu->addMenuOption(optionsButton, 0, 2);
	startMenu->addMenuOption(exitButton, 0, 3);
	
	MenuState* startMenuState = new MenuState(loadTexture("./img/back.jpg"), startMenu);
	
	SplashScreenState* splashScreen = new SplashScreenState(loadTexture("./img/logo.tga"), 8000, 3000, 2000);
	
	g_stateManager->registerState(startMenuState);
	g_stateManager->registerState(optionsMenuState);
	g_stateManager->registerState(splashScreen);
	g_stateManager->loadNewCurrentState(startMenuState);
	g_stateManager->loadNewCurrentState(splashScreen);
	
	TTF_CloseFont(font);
	g_quit = false;
}
Esempio n. 8
0
void ofxGuiInputField<Type>::generateDraw(){

	ofxGuiElement::generateDraw();

	generateText();
}
Esempio n. 9
0
int main (int argc, char** argv)
{
	if(argc>1)
	{
		OSCConn::setServer(argv[1]);
		if(argc>2)
		{
			OSCConn::setPort(atoi(argv[2])); 
		}
	}
	else
	{
		if(getSCPath() && launchSuperCollider());
		else
		{
			fprintf(stderr, "Cant get sclang patch - exiting\n");
			exit(0);
		}
	}
	
	registerEffects();
	registerControllers();
	
	if(!OSCConn::connect()) exit(1);
	
	if(!OSCConn::startServer()) exit(2);
	
	if(!checkEffectsList()) {OSCConn::quitServer(); exit(3);}
	
	saveSCPath();
	
	initSDL();
	
	effectCreator.init();
	
	recordingInfoTex=generateText("Recording", COLOR_SELECTED_TEXT);
	
	auto effectInstanceList=getEffectInstanceList();
	
	auto controllerInstanceList=getControllerInstanceList();
	
	
	while (!checkInputs())
	{
		for(auto it=controllerInstanceList->rbegin();it!=controllerInstanceList->rend();++it)
		{
			it->second->step();
		}
		
		setColor(COLOR_CLEARCOLOR);
		SDL_RenderClear(render);
		drawRecordingInfo();
		
		for(auto it=effectInstanceList->begin();it!=effectInstanceList->end();++it)
		{
			it->second->doSomething();
		}
		
		for(auto it=effectInstanceList->begin();it!=effectInstanceList->end();++it)
		{
			it->second->draw();
		}
		
		for(auto it=controllerInstanceList->rbegin();it!=controllerInstanceList->rend();++it)
		{
			it->second->draw();
		}

		drawConnections();
		
		int screen_width;
		SDL_GetWindowSize(window, &screen_width, NULL);

		effectCreator.draw(screen_width-EffectCreator::menu_period, 0);
		
		SDL_RenderPresent(render);
	}
	
	Effect::saveToFile("last_session.cello");
	
	Effect::clearAll();
	
	quitSDL();
	
	OSCConn::quitServer();
	fprintf(stderr, "Done\n");
}
Esempio n. 10
0
int main(int argc, char **argv)
{
    Wind wind;
    Extf extf;
    Main main[10];

    int running = 1;
    int flap = -1;
    int max = 0;
    int i;
    int test = 0;

    SDL_Init(SDL_INIT_EVERYTHING); 
    TTF_Init();


    /***** initiate program *****/
    initAll(&main, &wind, &max);

    initFlap(&main, &wind, &extf, &flap, &max);

    initGenString(&main);

    flap = 0;

    initExtf(&extf);

    int firstT = -1000000;
    int lastT = 0;
    int firstMT = -1000;
    int lastMT = 0;

    int firstFPS = -32;
    int lastFPS = 0;

    int newFlapF = 0;
    int newFlapL;

    while(running)
    {

        /***** checks if timers are done *****/
        for (i = 0; i < max; i++)
		  checkTimers(&main[i]);

        /***** creates text for current time *****/
        generateText(&main[flap], &wind, &firstT, &lastT, &test);
        
        /***** draws everything at 32 fps *****/
        lastFPS = SDL_GetTicks();
        if (lastFPS > firstFPS + 32)
        {
            render(&main, &wind, &flap, &max);
            firstFPS = lastFPS;
            lastMT = SDL_GetTicks();
            if (lastMT > firstMT + 32)
            {
                for (i = 0; i < max; i++)
                    generateMiniText(&main[i], &wind, &flap);
                firstMT = lastMT;
            }

        }
        
        /***** check for user action *****/
        processEvents(&main[flap], &extf, &flap, &running, &max);

        /***** creates a new flap *****/
        if (extf.newFlap)
            initFlap(&main, &wind, &extf, &flap, &max);

        SDL_Delay(4);
    }

    /***** shuts everything down safetly *****/
    for (int i = 0; i < max; i++)
        destTexture(&main[i]);
    SDL_Delay(80);
    shutAll(&main, &wind, &max);

    return 0;
}
Esempio n. 11
0
int main()
{
    //recordVideoFrames()

    cv::Mat3b img_top    = cv::imread("photos/IMG_6216.JPG", cv::IMREAD_COLOR);
    cv::Mat3b img_bottom = cv::imread("photos/IMG_6217.JPG", cv::IMREAD_COLOR);

    std::vector<cv::Point2f> points_top    = findLabelPositions(img_top);
    std::vector<cv::Point2f> points_bottom = findLabelPositions(img_bottom);

    Camera cam = solveCamera(points_top, points_bottom, img_top.size());
    const float label_width = 0.9f;
    analyzeVideo("video1", cam, label_width);

    setupWindows(img_bottom.size());

    std::vector<cv::Scalar> colors_top    = readLabelColors(img_top, points_top);
    std::vector<cv::Scalar> colors_bottom = readLabelColors(img_bottom, points_bottom);

    std::vector<cv::Scalar> label_colors;
    cv::hconcat(colors_top, colors_bottom, label_colors);
    std::vector<size_t> label_sides = assignColorsToSides(label_colors);

    cv::Mat3b canvas_top = img_top * 0.25f;
    cv::Mat3b canvas_bottom = img_bottom * 0.25f;

    std::vector<std::string> texts_top;
    for (int i = 0; i < 3*9; ++i)
    {
        texts_top.push_back(generateText(i, label_sides));
    }
    std::vector<std::string> texts_bottom;
    for (int i = 3*9; i < 6*9; ++i)
    {
        texts_bottom.push_back(generateText(i, label_sides));
    }

    drawLabelInfo(canvas_top, points_top, texts_top, cv::Scalar(255, 255, 255), 1.0);
    drawLabelInfo(canvas_bottom, points_bottom, texts_bottom, cv::Scalar(255, 255, 255), 1.0);

    cv::imshow("top", canvas_top);
    cv::imshow("bottom", canvas_bottom);

    cv::Mat3b canvas(cv::Size(25 * 3.1 * 6, 25 * 3), cv::Vec3b(0,0,0));

    for (int i = 0; i < 6*9; ++i)
    {
        int side = i / 9;
        int row = (i % 9) / 3;
        int col = i % 3;

        cv::Rect rect(cv::Point(25 * (side * 3.1 + col), 25 * row), cv::Size(25,25));
        cv::rectangle(canvas, rect, label_colors[i], cv::FILLED);
        cv::rectangle(canvas, rect, cv::Scalar(0,0,0), 1);
    }

    for (int i = 0; i < 6*9; ++i)
    {
        int side = i / 9;
        int row = (i % 9) / 3;
        int col = i % 3;

        cv::Point text_bl(25 * (side * 3.1 + col) + 2, 25 * row + 15);
        cv::putText(canvas, generateText(i, label_sides), text_bl,
            cv::FONT_HERSHEY_SIMPLEX, 0.5, cv::Scalar(0,0,0));
    }
    cv::imshow("colors", canvas);

    const std::vector<size_t> kociemba_order = {
        18, 19, 20, 21, 22, 23, 24, 25, 26, // U
         9, 10, 11, 12, 13, 14, 15, 16, 17, // R
         0,  1,  2,  3,  4,  5,  6,  7,  8, // F
        51, 48, 45, 52, 49, 46, 53, 50, 47, // D
        35, 34, 33, 32, 31, 30, 29, 28, 27, // L
        44, 43, 42, 41, 40, 39, 38, 37, 36, // B
    };
    std::stringstream ss;
    for (size_t i : kociemba_order)
    {
        ss << side_names[label_sides[i]];
    }
    printf("Cube state: %s\n", ss.str().c_str());
    fflush(stdout);

    twophase::Search search;
    std::string solution = search.solution(ss.str(), 18, 15, false);
    printf("Solution: %s\n", solution.c_str());
    fflush(stdout);

    cv::Mat3b solution_img = drawMoveSequence(solution);
    cv::imshow("solution", solution_img);

    cv::waitKey();
    return 0;
}
Esempio n. 12
0
void GameConversations::update(bool flag) {
	// Only need to proceed if there is an active conversation
	if (!active())
		return;

	ConversationVar &var0 = _runningConv->_cnd._vars[0];

	switch (_currentMode) {
	case CONVMODE_0:
		assert(var0.isNumeric());
		if (var0._val < 0) {
			if (_vm->_game->_scene._frameStartTime >= _startFrameNumber) {
				removeActiveWindow();
				if (_heroTrigger) {
					_vm->_game->_scene._action._activeAction._verbId = _verbId;
					_vm->_game->_trigger = _heroTrigger;
					_vm->_game->_triggerMode = _heroTriggerMode;
					_heroTrigger = 0;
				}

				_currentMode = CONVMODE_STOP;
			}
		} else {
			bool isActive = nextNode();
			_currentNode = var0._val;

			if (isActive) {
				_verbId = _runningConv->_data._nodes[_currentNode]._index;
				_vm->_game->_scene._action._activeAction._verbId = _verbId;
				_vm->_game->_scene._action._inProgress = true;
				_vm->_game->_scene._action._savedFields._commandError = false;
				_currentMode = CONVMODE_1;
			} else {
				_currentMode = generateMenu();
			}
		}
		break;

	case CONVMODE_1:
		if (flag)
			_currentMode = CONVMODE_3;
		break;

	case CONVMODE_2:
		if (flag) {
			_vm->_game->_player._stepEnabled = false;
			_verbId = _vm->_game->_scene._action._activeAction._verbId;

			if (!(_runningConv->_cnd._entryFlags[_verbId] & ENTRYFLAG_2))
				flagEntry(CMD_HIDE, _verbId);

			removeActiveWindow();
			_vm->_game->_scene._userInterface.emptyConversationList();
			_vm->_game->_scene._userInterface.setup(kInputConversation);
			_personSpeaking = 0;
			executeEntry(_verbId);

			ConvDialog &dialog = _runningConv->_data._dialogs[_verbId];
			if (dialog._speechIndex) {
				_runningConv->_cnd._messageList3.clear();
				_runningConv->_cnd._messageList3.push_back(dialog._speechIndex);
			}

			generateText(dialog._textLineIndex, _runningConv->_cnd._messageList3);
			_currentMode = CONVMODE_0;

			if (_heroTrigger) {
				_vm->_game->_scene._action._activeAction._verbId = _verbId;
				_vm->_game->_trigger = _heroTrigger;
				_vm->_game->_triggerMode = _heroTriggerMode;
				_heroTrigger = 0;
			}
		}
		break;

	case CONVMODE_3:
		if (_vm->_game->_scene._frameStartTime >= _startFrameNumber) {
			removeActiveWindow();
			_personSpeaking = 0;
			executeEntry(_verbId);
			generateMessage(_runningConv->_cnd._messageList1, _runningConv->_cnd._messageList3);
		
			if (_heroTrigger && _popupVisible) {
				_vm->_game->_scene._action._activeAction._verbId = _verbId;
				_vm->_game->_trigger = _heroTrigger;
				_vm->_game->_triggerMode = _heroTriggerMode;
				_heroTrigger = 0;
			}

			_currentMode = CONVMODE_4;
		}
		break;

	case CONVMODE_4:
		if (_vm->_game->_scene._frameStartTime >= _startFrameNumber) {
			removeActiveWindow();
			_personSpeaking = _speakerVal;

			generateMessage(_runningConv->_cnd._messageList2, _runningConv->_cnd._messageList4);

			if (_interlocutorTrigger && _popupVisible) {
				_vm->_game->_scene._action._activeAction._verbId = _verbId;
				_vm->_game->_trigger = _interlocutorTrigger;
				_vm->_game->_triggerMode = _interlocutorTriggerMode;
				_interlocutorTrigger = 0;
			}
		}
		break;

	case CONVMODE_STOP:
		stop();
		break;

	default:
		break;
	}

	warning("TODO: GameConversations::update");
}