Example #1
0
void ts::graphics::Texture::load_from_file(const std::string& file_name, Rect<int> rect)
{
    sf::Image image;
    if (!image.loadFromFile(file_name)) {
        throw std::runtime_error("could not open image file \"" + file_name + "\"");
    }
            
    load_from_image(image);
}
Example #2
0
void ggEditor::tick( sf::Window* window )
{
    if ( *currentController != CTRL_EDITOR ) {
        return;
    }
    
    i->wspawn_count = wspawn_count;

    // If play pressed, hand control over to game.
    if ( i->btnPlay.doAction ) {
        i->btnPlay.doAction = false;
        i->loadInitialCellPattern();
        *currentController = CTRL_GAME;
    }
    if ( i->btnStop.doAction ) i->btnStop.doAction = false;
    if ( i->btnPause.doAction ) i->btnPause.doAction = false;
    if ( i->btnReset.doAction ) {
        wspawn_count = 0;
        seed_count = 0;
        i->btnReset.doAction = false;
    }
    if ( i->btnSave.doAction ) {
        i->btnSave.doAction = false;
        std::string pathFileName = pop_file_dialog( DIALOG_SAVE, "\\patterns\\", window->getSystemHandle() );
        if ( pathFileName != "" ) {
            save_as_image( pathFileName, i->cellsInitial );
        }
    }
    if ( i->btnLoad.doAction ) {
        i->btnLoad.doAction = false;
        // TODO -> Figure out how to update seed and fountain count after loading
        std::string pathFileName = pop_file_dialog( DIALOG_OPEN, "\\patterns\\", window->getSystemHandle() );
        if ( pathFileName.find("GardenGrow.exe") != std::string::npos ) {
            i->flagHelp = true;
        } else {
            i->flagHelp = false;
        }
        if ( pathFileName != "" ) {
            load_from_image( pathFileName, i->cellsInitial );
            updateCount();
            i->panX = 0.0f;
            i->panY = 0.0f;
            i->zoomLevel = 1.0f;
        }
    }
}
Example #3
0
ts::graphics::Texture::Texture(const sf::Image& image, Rect<int> rect)
{
    load_from_image(image, rect);
}