Пример #1
0
/*airplane constructor reads conf file and intializes menu controls in mediator(mainwindow)*/
airplane::airplane(nmainwindow *m):w(NULL),mediator(m) {
trace("airplane::airplane")
 timer=new QTimer(this);
 connect(timer,SIGNAL(timeout()),this,SLOT(refreshmap()));
 readfile(":/conf.txt");
 cmenu=mediator->menuBar()->addMenu(tr("map"));
 roadmapaction=new QAction(tr("ROADMAP"),cmenu);
 satelliteaction=new QAction(tr("SATELLITE"),cmenu);
 hybridaction=new QAction(tr("HYBRID"),cmenu);
 terrainaction=new QAction(tr("TERRAIN"),cmenu);
 ctrlmenu=mediator->menuBar()->addMenu(tr("ctrl"));
 pauseaction=new QAction(tr("pause"),ctrlmenu);
 slideraction=new QAction(tr("slider"),ctrlmenu);
 snapshotaction=new QAction(tr("snapshot"),ctrlmenu);
aboutaction=new QAction(tr("about"),mediator->menuBar());
 connect(roadmapaction,SIGNAL(triggered()),this,SLOT(roadmaptriggered()));
 connect(satelliteaction,SIGNAL(triggered()),this,SLOT(satellitetriggered()));
 connect(terrainaction,SIGNAL(triggered()),this,SLOT(terraintriggered()));
 connect(hybridaction,SIGNAL(triggered()),this,SLOT(hybridtriggered()));
 connect(pauseaction,SIGNAL(triggered()),this,SLOT(pausetriggered()));
 connect(slideraction,SIGNAL(triggered()),this,SLOT(slider()));
 connect(snapshotaction,SIGNAL(triggered()),this,SLOT(snapshottriggered()));
connect(aboutaction,SIGNAL(triggered()),this,SLOT(abouttriggered()));
 cmenu->addAction(roadmapaction);
 cmenu->addAction(satelliteaction);
 cmenu->addAction(hybridaction);
 cmenu->addAction(terrainaction);
 ctrlmenu->addAction(pauseaction);
 ctrlmenu->addAction(slideraction);
 ctrlmenu->addSeparator();
 ctrlmenu->addAction(snapshotaction);
mediator->menuBar()->addAction(aboutaction);
 pzRot=plineindex=lineindex=0;
trace("~airplane::airplane")
}
Пример #2
0
void MapEditor::autowall() {
    int y1 = csr->y;
    int x1 = csr->x;
    int y2, x2, c;
    
    printwdlg("auto wall mode on, press 'a' again to confirm wall location");
    
    while ((c = getch()) != 'a') {
        // allow cursor movement
        switch (c) {
            case KEY_LEFT:
            case KEY_RIGHT:
            case KEY_UP:
            case KEY_DOWN:
                refreshmap();
                mvcsr(c);
                y2 = csr->y;
                x2 = csr->x;
                // create walls preview
                for (int i = y1; i <= y2; i++) {
                    mvwprintw(stdscr, i, x1, "#");
                    mvwprintw(stdscr, i, x2, "#");
                }
                for (int i = x1; i <= x2; i++) {
                    mvwprintw(stdscr, y1, i, "#");
                    mvwprintw(stdscr, y2, i, "#");
                }
                refresh();
                break;
            default:
                printwdlg("error: only arrow keys are accepted");
                break;
        }
    }
    // confirm placement of the walls
    // destroying all previous data's
    for (int i = y1; i <= y2; i++) {
        pmap->setAtLocation(i, x1, MapObject(i, x1, WALL));
        pmap->setAtLocation(i, x2, MapObject(i, x1, WALL));
    }            
    for (int i = x1; i <= x2; i++) {
        pmap->setAtLocation(y1, i, MapObject(y1, i, WALL));
        pmap->setAtLocation(y2, i, MapObject(y2, i, WALL));
    }
    refreshmap();
    printwdlg("auto wall mode completed");
}
Пример #3
0
void MapEditor::addatcsr(int c) {
    MapObjectType tmp;
    switch (c) {
        case 'w':
            tmp = WALL; 
            break;
        case 'p':
            tmp = PLAYER;
            // remove the old player
            for (int i = 0; i < STD_Y; i++) {
                for (int j = 0; j < STD_X; j++) {
                    if ((pmap->getAtLocation(i, j))->mapObjectType == PLAYER)
                        pmap->setAtLocation(i, j, MapObject(i, j, EMPTY));
                }
            }
            break;
        case 'e':
            tmp = ENTRANCE;
            // remove the old door
            for (int i = 0; i < STD_Y; i++) {
                for (int j = 0; j < STD_X; j++) {
                    if ((pmap->getAtLocation(i, j))->mapObjectType == ENTRANCE)
                        pmap->setAtLocation(i, j, MapObject(i, j, EMPTY));
                }
            }
            break;
        case 'x':
            tmp = EXIT;
            // remove the old exit
            for (int i = 0; i < STD_Y; i++) {
                for (int j = 0; j < STD_X; j++) {
                    if ((pmap->getAtLocation(i, j))->mapObjectType == EXIT)
                        pmap->setAtLocation(i, j, MapObject(i, j, EMPTY));
                }
            }
            break;
        case 'c':
            tmp = TREASURE_CHEST;
            break;
        case 'm':
            tmp = MONSTER;
            break;
        case 'r':
            tmp = EMPTY;
            break;
        case 't':
            tmp = MERCHANT;
            break;
        default:
            tmp = EMPTY;
            break;
    }
    pmap->setAtLocation(csr->y, csr->x, MapObject(csr->y, csr->x, tmp));
    refreshmap();
}
Пример #4
0
MapEditor::MapEditor(std::string name) {
    // ncurses initialization funcs
    initscr();
    noecho();
    curs_set(0);
    raw();
    keypad(stdscr, TRUE);
    wclear(stdscr);
    refresh();
    // end of ncurses initialization funcs
    
    // initialize member variables
    csr = new Cursor();
    pmap = new Map(name);
    wlgd = createLegendWindow();
    wdlg = createDialogueWindow();
    
    // attach itself to the observers
    pmap->attach(this);
    
    // flush the map 
    refreshmap();
    
    // show the cursor
    mvcsr(NULL);
    
    // set the initial cursor to blinking
    MapObject* tmp = pmap->getAtLocation(csr->y, csr->x);
    attron(A_BLINK | A_UNDERLINE);
    mvwprintw(stdscr, csr->y, csr->x, "%c", static_cast<char>(tmp->mapObjectType));
    attroff(A_BLINK | A_UNDERLINE);
    refresh();
    
    // go edit mode
    edit();
    
    // end ncurses
    endwin();
}
Пример #5
0
MapEditor::MapEditor() {
    // ncurses initialization funcs
    initscr();
    noecho();
    curs_set(0);
    raw();
    keypad(stdscr, TRUE);
    wclear(stdscr);
    refresh();
    // end of ncurses initialization funcs
    
    // initialize member variables
    csr = new Cursor();
    pmap = new Map();
    wlgd = createLegendWindow();
    wdlg = createDialogueWindow();
    
    // attach itself to the observers
    pmap->attach(this);
    
    // flush the map
    refreshmap();
    
    // show the cursor
    mvcsr(NULL);
    
    // set the initial cursor to blinking
    attron(A_BLINK);
    mvwprintw(stdscr, csr->y, csr->x, "_");
    attroff(A_BLINK);
    refresh();
    
    // go edit mode
    edit();
    
    // end ncurses
    endwin();
}