void PlayControllerMsgCenter::mouseEntered( gcn::MouseEvent& mouseEvent )
{
  model().setMouse( "MsgCenter",
                    mouseEvent.getX(),
                    mouseEvent.getY() );
  mouseEvent.consume();
}
Exemplo n.º 2
0
void PlayControllerZone::mouseReleased( gcn::MouseEvent& mouseEvent )
{

  model().setMouse( "ZoneO",
                    mouseEvent.getX(),
                    mouseEvent.getY() );

  //
  // Tenemos un area para seleccionar.
  adjustSelectedArea( mouseEvent.getX(),
                      mouseEvent.getY() );

  switch ( mouseEvent.getButton() )
  {
    case gcn::MouseEvent::LEFT:
      view().setSelectedArea( m_selectarea );
      break;
    case gcn::MouseEvent::RIGHT:
      view().setDestination( m_selectarea );
      break;
    default:
      break;
  }

  mouseEvent.consume();
}
Exemplo n.º 3
0
void ItemMakerBox::mouseClicked(gcn::MouseEvent& mouseEvent){
    if( mouseEvent.isConsumed() ){ return; };

    //  Save Button
    if( mouseEvent.getSource() == saveBtn ){
        mouseEvent.consume();
        save( filenameFld->getText() );
    } else
    //  Load Button
    if( mouseEvent.getSource() == loadBtn ){
        mouseEvent.consume();
        load( filenameFld->getText() );
    } else {
        setCaption(caption_);
    }
}
Exemplo n.º 4
0
void ListBox::mouseWheelMovedDown(gcn::MouseEvent& mouseEvent)
{
    if (isFocused())
    {
        incrementSelected();
        mouseEvent.consume();
    }
}
Exemplo n.º 5
0
void PlayControllerZone::mouseExited( gcn::MouseEvent& mouseEvent )
{

  model().resetMouse();
  view().resetMove();
  mouseEvent.consume();

}
Exemplo n.º 6
0
void GuiTable::mouseWheelMovedDown(gcn::MouseEvent& mouseEvent)
{
    if (isFocused())
    {
        setSelectedRow(getSelectedRow() + 1);

        mouseEvent.consume();
    }
}
Exemplo n.º 7
0
void PlayControllerZone::mouseWheelMovedDown( gcn::MouseEvent & mouseEvent )
{

  model().setMouse( "Zone",
                    mouseEvent.getX(),
                    mouseEvent.getY() );
  view().moveView( 0,
                   +10 );
  mouseEvent.consume();
}
Exemplo n.º 8
0
void PlayControllerZone::mouseEntered( gcn::MouseEvent& mouseEvent )
{

  model().setMouse( "Zone",
                    mouseEvent.getX(),
                    mouseEvent.getY() );
  view().updateMoveView( mouseEvent.getX(),
                         mouseEvent.getY() );
  mouseEvent.consume();

}
Exemplo n.º 9
0
void GuiTable::mouseWheelMovedUp(gcn::MouseEvent& mouseEvent)
{
    if (isFocused())
    {
        if (getSelectedRow() > 0 || (getSelectedRow() == 0 && mWrappingEnabled))
        {
            setSelectedRow(getSelectedRow() - 1);
        }

        mouseEvent.consume();
    }
}
Exemplo n.º 10
0
void ChatInput::mouseWheelMovedUp(gcn::MouseEvent& mouseEvent)
{
    TextField::mouseWheelMovedUp(mouseEvent);

    if (isFocused() && mCurHist != mHistory.begin() && mHistory.size() > 0)
    {
        // Move backward through the history
        mCurHist--;
        setText(*mCurHist);
        setCaretPosition(getText().length());
        mouseEvent.consume();
    }
}
Exemplo n.º 11
0
void PlayControllerZone::mouseDragged( gcn::MouseEvent& mouseEvent )
{

  model().setMouse( "ZoneE",
                    mouseEvent.getX(),
                    mouseEvent.getY() );

  adjustSelectedArea( mouseEvent.getX(),
                      mouseEvent.getY() );

  view().paintSelectedArea( m_selectarea );
  mouseEvent.consume();
}
Exemplo n.º 12
0
void PlayControllerZone::mousePressed( gcn::MouseEvent& mouseEvent )
{

  model().setMouse( "ZoneX",
                    mouseEvent.getX(),
                    mouseEvent.getY() );

  m_firstselect.x = mouseEvent.getX();
  m_firstselect.y = mouseEvent.getY();

  m_selectarea.x = m_firstselect.x;
  m_selectarea.y = m_firstselect.y;
  m_selectarea.width = 0;
  m_selectarea.height = 0;

  mouseEvent.consume();

}
Exemplo n.º 13
0
void ChatInput::mouseWheelMovedDown(gcn::MouseEvent& mouseEvent)
{
    TextField::mouseWheelMovedDown(mouseEvent);

    if (isFocused() && mCurHist != mHistory.end())
    {
        // Move forward through the history
        HistoryIterator prevHist = mCurHist++;

        if (mCurHist != mHistory.end())
        {
            setText(*mCurHist);
            setCaretPosition(getText().length());
        }
        else
            mCurHist = prevHist;

        mouseEvent.consume();
    }
}
Exemplo n.º 14
0
void PlayControlPanel::mouseClicked(gcn::MouseEvent &mouseEvent)
{
  if (mouseEvent.isConsumed()) {
    return;
  }

  gcn::Widget* sourceWidget = mouseEvent.getSource();
  if (sourceWidget == dynamic_cast<gcn::Widget*>(playButton)) {
    std::cout << "Click on PLAY button" << std::endl;
    changeState(PLAYING);
  } else if (sourceWidget == dynamic_cast<gcn::Widget*>(pauseButton)) {
    std::cout << "Click on PAUSE button" << std::endl;
    changeState(PAUSED);
  } else if (sourceWidget == dynamic_cast<gcn::Widget*>(stopButton)) {
    std::cout << "Click on STOP button" << std::endl;
    changeState(STOPPED);
  }

  mouseEvent.consume();
}
Exemplo n.º 15
0
void MouseSelectionMenu::mouseClicked(gcn::MouseEvent &mouseEvent)
{
    WidgetListIterator iter;
    for (iter = mWidgets.begin(); iter != mWidgets.end(); iter++) {
        gcn::Rectangle rec = (*iter)->getDimension();
        if( (*iter)->getY() <= mouseEvent.getY() && (*iter)->getY() + (*iter)->getHeight() >= mouseEvent.getY() &&
            (*iter)->getX() <= mouseEvent.getX() && (*iter)->getX() + (*iter)->getWidth()  >= mouseEvent.getX() ) {
            SDL_Event event;

            Gui::current().removeWidget(this);

            event.type = SDL_USEREVENT;
            event.user.code = EVENT_DELETE_WIDGET;
            event.user.data1 = this;

            SDL_PushEvent(&event);
            break;
        }
    }

    mouseEvent.consume();
    return;
}
Exemplo n.º 16
0
void DropDown::mouseWheelMovedDown(gcn::MouseEvent& mouseEvent)
{
    setSelected(getSelected() + 1);
    mouseEvent.consume();
}
Exemplo n.º 17
0
void MapperGui::mouseClicked(gcn::MouseEvent& mouseEvent){
    if( mouseEvent.isConsumed() ){ return; };

    //click from the map image ( worldImagePlaceHolder )
    if( mouseEvent.getSource() == worldImagePlaceHolder ){
        //consume mouse event
        mouseEvent.consume();
        //click from the tilesetImage
        if( world != NULL ){
            if( world->empty() ){ return; };

            int layerNum = layerToggleBox->getWorkingLayer();
            Layer& workingLayer = world->getLayer(layerNum);

            // tileset select
            int tileWidth = workingLayer.getTileWidth();
            int tileHeight = workingLayer.getTileHeight();

            // get the x-y co-ords reletive to the tileset region
            int col = mouseEvent.getX() - worldImagePlaceHolder->getX();
            int row = mouseEvent.getY() - worldImagePlaceHolder->getY();

            // if its a multiple of tilewidth/height (ie in the barrier between)
            if( col % tileWidth == 0){ ++col; };
            if( row % tileHeight == 0){ ++row; };

            // turn co-ords into row/col
            col = col/tileWidth;
            row = row/tileHeight;


            // calculate the amount of tiles off the screen
            int trueCol = worldImagePlaceHolder->getX();
            int trueRow = worldImagePlaceHolder->getY();

            //  if its a multiple of tilewidth/height (ie in the barrier between)
            if( trueCol % tileWidth == 0){ ++col; };
            if( trueRow % tileHeight == 0){ ++row; };
            // turn co-ords into row/col
            trueCol = trueCol/tileWidth;
            trueRow = trueRow/tileHeight;
            //add the on screen offset to the offsecreen tiles
            trueCol += col-1;
            trueRow += row-1;

            //check if within range
            if( (trueCol < workingLayer.getWidth()) &&
                (trueRow < workingLayer.getHeight()) ){
                //if left click
                if( mouseEvent.getButton() == gcn::MouseEvent::LEFT ){
                    //set the tile wher mouse is on map, to selected tile on ts
                    //if the attrib ts is on
                    if( tilesetBox->getSelectedTileset() == tilesetBox->getAttribTileset() ){
                        //only replace the attibute
                        workingLayer.at(trueCol, trueRow).setAttribute( tilesetBox->getSelectedTile().getAttribute() );
                    } else {
                        //replace old tile
                        workingLayer.at(trueCol, trueRow) = tilesetBox->getSelectedTile();
                    }
                } else if( mouseEvent.getButton() == gcn::MouseEvent::MIDDLE ){
                    //fill layer, to selected tile on ts
                    //if the attrib ts is on
                    if( tilesetBox->getSelectedTileset() == tilesetBox->getAttribTileset() ){
                        //only replace the attibute
                        for(int i = 0; i < workingLayer.getHeight(); ++i){
                            for(int j = 0; j < workingLayer.getWidth(); ++j){
                                workingLayer.at(j, i).setAttribute( tilesetBox->getSelectedTile().getAttribute() );
                            }
                        }
                    } else {
                        //replace old tile
                        for(int i = 0; i < workingLayer.getHeight(); ++i){
                            for(int j = 0; j < workingLayer.getWidth(); ++j){
                                workingLayer.at(j, i) = tilesetBox->getSelectedTile();
                            }
                        }
                    }
                } else if ( mouseEvent.getButton() == gcn::MouseEvent::RIGHT ){
                    //if the attrib ts is on
                    if( tilesetBox->getSelectedTileset() == tilesetBox->getAttribTileset() ){
                        //clear attrib
                        workingLayer.at(trueCol, trueRow).setAttribute( MapTile::REGULAR );
                    } else {
                        //clear the tileset (delete tile)
                        workingLayer.at(trueCol, trueRow).setSource( NULL, 0, 0 );
                    }
                }
                mapTouched = 1;
            }
        }//end if event from drop down
    } else




    //click from the tilset panel
    //load tileset button
    if( mouseEvent.getSource() == tilesetBox->getLoadTilesetButton() ){
        mouseEvent.consume();
        loadTilesetBox->setVisible( true );
        loadTilesetBox->requestFocus();
    } else

    //make tileset button
    if( mouseEvent.getSource() == tilesetBox->getMakeTilesetButton() ){
        mouseEvent.consume();
        makeTilesetBox->setVisible( true );
        makeTilesetBox->requestFocus();
    } else

    //close tileset button
    if( mouseEvent.getSource() == tilesetBox->getCloseTilesetButton() ){
        mouseEvent.consume();
        tilesetDetailsBox->setInfoSource( NULL );
    } else

    //display tileset info
    if( mouseEvent.getSource() == tilesetBox->getTilesetDetailsButton() ){
        mouseEvent.consume();
        tilesetDetailsBox->setInfoSource( tilesetBox->getSelectedTileset() );
        tilesetDetailsBox->setVisible( true );
        tilesetDetailsBox->requestFocus();
    } else




    // from file tool bar
    //new doc
    if( mouseEvent.getSource() == fileToolBar->getNewDocButton() ){
        mouseEvent.consume();
        loadMapBox->setVisible( true );
        loadMapBox->requestFocus();
    } else

    //save document
    if( mouseEvent.getSource() == fileToolBar->getSaveDocButton() ){
        mouseEvent.consume();
        if( world == NULL ){
            alert("Theres no map to save (try the new map button =P)");
            return;
        }
        if( world->size() == 0 ){
            alert("Theres no map to save (try the new map button =P)");
            return;
        }
        std::string a =  world->getFilename() ;
        if( world->getFilename() == "NULL" || world->getFilename().empty() ||
            isSpace(world->getFilename())  || world->getFilename() == "" ){
            filenameBox->setFilename("data/maps/");
            filenameBox->setVisible( true );
            action = SAVEAS;
        } else {
            if( !world->saveMap(world->getFilename()) ){
                alert( ("Cant save file: " + world->getFilename()) );
                return;
            } else {
                alert("Saved");
            }
        }
    } else

    // save as
    if( mouseEvent.getSource() == fileToolBar->getSaveAsButton() ){
        mouseEvent.consume();
        if( world == NULL ){
            alert("Theres no map to save (try the new map button =P)");
            return;
        }
        if( world->size() == 0 ){
            alert("Theres no map to save (try the new map button =P)");
            return;
        }
        action = SAVEAS;
        filenameBox->setFilename("data/maps/");
        filenameBox->setVisible( true );
    } else

    //open new doc (close current 1st)
    if( mouseEvent.getSource() == fileToolBar->getOpenDocButton() ){
        mouseEvent.consume();
        action = OPEN;
        filenameBox->setFilename("data/maps/");
        filenameBox->setVisible( true );
    } else









    //close (no save) and reOpen
    if( mouseEvent.getSource() == fileToolBar->getReopenDocButton() ){
        mouseEvent.consume();
        if( world != NULL ){
            std::string filename = correctFilepath(world->getFilename());
            //delete map
            notify("Releasing old world from memory");
            world->unload();
            //clear the tileset array
            notify("Releasing tilesets");
            tilesetBox->freeTilesets();
            //reopen
            notify("Reopening file");
            if( !world->loadMap(filename) ){
                alert( ("Cant open file: " + filename) );
            }
            unNotify();
            mapDetailsBox->setInfoSource( world );
            //  free old worldImage
            if( worldImage != NULL ){
                SDL_FreeSurface(worldImage);
                worldImage = NULL;
            };
            mapTouched = 1;
            action = NOTHING;
        }
    } else

    //close
    if( mouseEvent.getSource() == fileToolBar->getCloseDocButton() ){
        mouseEvent.consume();
        //delete map
        notify("Releasing old world from memory");
        if( world != NULL ){
            //delete worlds
            world->unload();
            //clear the tileset array
            notify("Releasing tilesets");
            tilesetBox->freeTilesets();
            unNotify();
            mapDetailsBox->setInfoSource( world );
            //  free old worldImage
            if( worldImage != NULL ){
                SDL_FreeSurface(worldImage);
                worldImage = NULL;
            }
            mapTouched = 1;
            action = NOTHING;
        }
    } else

    //get details
    if( mouseEvent.getSource() == fileToolBar->getDetailsButton() ){
        mouseEvent.consume();
        mapDetailsBox->setVisible( true );
    }
}
void PlayControllerMsgCenter::mouseExited( gcn::MouseEvent& mouseEvent )
{
  model().resetMouse();
  mouseEvent.consume();
}
Exemplo n.º 19
0
void MapperTilesetBox::mouseClicked(gcn::MouseEvent& mouseEvent){
    InfraellyWindow::mouseClicked(mouseEvent);

    if( mouseEvent.isConsumed() ){ return; };

    //if click was from closeTilesetButton
    if( mouseEvent.getSource() == closeTilesetButton ){
        //consume mouse event
        mouseEvent.consume();
        //get the pointer to the tileset to remove
        Tileset *toRemove = tilesetList->at( tilesetDropDown->getSelected() );

        //check if the user is trying to dlete teh nullTS
        if( toRemove != tilesetList->at(0) ){
            //store number to remove
            int removeIndex = tilesetDropDown->getSelected();
            //change the selected ts to the nullTS
            tilesetDropDown->setSelected(0);
            //delete the entry from teh list
            tilesetList->removeElementAt( removeIndex );


            //if there is a map activley associated
            if( world != NULL ){
                //stip dependency from map working on
                //if there IS dependency
                if( !world->empty() ){
                    //cycle through layers
                    for( size_t i = 0; i < world->size(); ++i ){
                        //cycle thru tiles
                        for( size_t j = 0; j < world->getLayer(i).getHeight() * world->getLayer(i).getWidth(); ++j){
                            if( world->getLayer(i).index(j).getTileset() == toRemove ){
                                world->getLayer(i).index(j).setTileset(NULL);
                            }
                        }
                    }
                }
            }
            //dependency of tileset stripped
            //delete the tileset
            cache::tilesets.erase(toRemove);

            //remove from selected tile
            selectedTile.setSource(NULL,0,0);
        }
    }


    //click from the tilesetImage
    if( mouseEvent.getSource() == tilesetImage ){
        //consume mouse event
        mouseEvent.consume();
        if( !tilesetList->empty() ){
            Tileset *selectedTs = selectedTile.getTileset();
            if( selectedTs != NULL ){
                // tileset select
                int tileWidth = selectedTs->getTileWidth();
                int tileHeight = selectedTs->getTileHeight();

                // get the x-y co-ords reletive to the tileset region
                int col = mouseEvent.getX() - (tilesetImage->getX()+selectedTs->getXOffset());
                int row = mouseEvent.getY() - (tilesetImage->getY()+selectedTs->getYOffset());

                // if its a multiple of tilewidth/height (ie in the barrier between)
                if( col % tileWidth == 0){ ++col; };
                if( row % tileHeight == 0){ ++row; };

                // turn co-ords into row/col
                col = col/tileWidth;
                row = row/tileHeight;


                // calculate the amount of tiles off the screen
                int trueCol = tilesetImage->getX();
                int trueRow = tilesetImage->getY();

                //  if its a multiple of tilewidth/height (ie in the barrier between)
                if( trueCol % tileWidth == 0){ ++col; };
                if( trueRow % tileHeight == 0){ ++row; };
                // turn co-ords into row/col
                trueCol = trueCol/tileWidth;
                trueRow = trueRow/tileHeight;
                //add the on screen offset to the offsecreen tiles
                trueCol += col-1;
                trueRow += row-1;

                //store the tile's new row-col
                selectedTile.setSource( selectedTs, trueCol, trueRow);
                //store attribute if on atrib ts
                if( selectedTile.getTileset() == attribTs ){
                    selectedTile.setAttribute(attribGrid[trueCol][trueRow]);
                }
            }// end if null
        }//end if empty list
    }//end if event from drop down*/
}