Beispiel #1
0
ToolBar::ToolBar(const QMap<InstrumentsEnum, QAction *> &actMap, QWidget *parent) :
    QToolBar(tr("Instruments"), parent), mActMap(actMap)
{
    setMovable(false);
    initializeItems();
    mPrevInstrumentSetted = false;
}
Beispiel #2
0
MainWindow::MainWindow(QWidget * parent)
    : QMainWindow(parent)
    , m_ui(new Ui::MainWindow())
    , m_harmonics(new HarmonicCollection())
    , m_factory(new HarmonicFactory())
    , m_provider(new HarmonicPlotItemsProvider(Math::Range(-5, 5), 0.05))
{
    m_ui->setupUi(this);
    initializeItems();
}
Beispiel #3
0
int main(int argc, char** argv) {
    (void) argc;
    (void) argv;
    /*srand(time(NULL));*/
#ifdef WIN32
    {
        LARGE_INTEGER divisor;
        QueryPerformanceFrequency(&divisor);
        clockDivisor = divisor.QuadPart;
    }
#else
    clockDivisor = CLOCKS_PER_SEC;
#endif
    printf("Starting\nClock divisor: %lu\n", clockDivisor);

    struct graphics g = {
#ifdef SHOWKEYS
        .width = 100, .height = 100,
#else
        .width = 1200,
        .height = 900,
#endif
    };
    initiateGraphics(&g, "Test window");

    if(!g.window) goto CLEANUP;
    /*thread t;*/
    /*newThread(test, NULL, &t);*/

    clockType frameStart, frameEnd, gameStart;
    getClockTime(&frameStart);

    initLogic();
    loadEntities();
    loadTileTextures();
    initializeWorld();
    initializeBullets();
    initializeItems();
    initializeItemFunctions();
    luaStart();

    getClockTime(&gameStart);

    while(1){
        cameraTick();
        renderGraphics(&g);

        oldMouseState = mouseState;
        mouseState = SDL_GetMouseState(&mouseX, &mouseY);
        if(oldMouseState != mouseState){
            mouseEvent();
        }
        for(SDL_Event event; SDL_PollEvent(&event);){
            switch(event.type){
            case SDL_QUIT:
                goto CLEANUP;
            case SDL_KEYDOWN:
            case SDL_KEYUP:
                if(event.key.keysym.scancode == 0x14) goto CLEANUP; //TODO
                keyEvent(event.key);
            break;
            }
        }

        getClockTime(&frameEnd);
        frameTime = getDiffClock(frameStart, frameEnd);
        appTime = getDiffClock(gameStart, frameEnd);
        frameStart = frameEnd;
        gameUpdate();
    }
CLEANUP:

    luaEnd();
    uninitializeItems();
    uninitializeItemFunctions();
    uninitializeBullets();
    uninitializeWorld();
    unloadTileTextures();
    unloadEntities();
    destroyGraphics(&g);

    return 0;
}

float normalRandomFloat(){
    return ((float) rand()) / ((float) RAND_MAX);
}

float randomFloat(float a, float b){
    float diff = b - a;
    return a + normalRandomFloat() * diff;
}
void GameCore::startOgre()
{
    reader=new ConfigReader(gameConfigFile);
    if(reader->readFile())
    {
        writer=new ConfigWriter(gameConfigFile);
        writer->importConfigReader(reader);
        reader->pushConfigFile("GameSettings");
        std::string pluginsConfig = reader->getFieldValueAsString("ConfigFiles", "plugins-configfile");
        std::string resourcesConfig = reader->getFieldValueAsString("ConfigFiles", "resources-configfile");
        std::string ogreConfig = reader->getFieldValueAsString("ConfigFiles", "ogre-config");
        std::string ogreLogFile = reader->getFieldValueAsString("LogFiles", "ogre-logfile");
        std::string gameLogFile = reader->getFieldValueAsString("LogFiles", "game-logfile");

        serverTcpPort= reader->getFieldValueAsInteger("NetworkSettings", "tcp-port");
        ttftpPort = reader->getFieldValueAsInteger("NetworkSettings", "ttftp-client-port");
        nickname=reader->getFieldValueAsString("MultiplayerSettings","nickname");
        wallHeight = reader->getFieldValueAsDouble("MapSettings", "wall-height");
        mapPath = reader->getFieldValueAsString("MapSettings", "map-lookup-directory");
        shadowsEnabled = reader->getFieldValueAsBool("GraphicsSettings", "shadows");
        menuBackgroundMusic = reader->getFieldValueAsString("GameSounds", "menu-background");
        gameBackgroundMusic = reader->getFieldValueAsString("GameSounds", "game-background");
        lmgFireSound = reader->getFieldValueAsString("GameSounds", "lmg-fire");
        bgSoundVolume=reader->getFieldValueAsDouble("GameSounds","bg-sound-volume");
        bgSoundVolume=(bgSoundVolume<-1?.1:bgSoundVolume);
		(reader->getFieldValueAsString("MultiplayerSettings","player-color")=="blue"?color=0:color=1);

        maxDecals=reader->getFieldValueAsInteger("GraphicsSettings","max-decals");
        if(maxDecals==-1)
            maxDecals=30;

        sensivity=((reader->getFieldValueAsDouble("MultiplayerSettings","mouse-sensivity")<=0?5:reader->getFieldValueAsDouble("MultiplayerSettings","mouse-sensivity")));


        moveAnimationSpeed = reader->getFieldValueAsDouble("AnimationSpeeds", "move-speed");
        fireAnimationSpeed = reader->getFieldValueAsDouble("AnimationSpeeds", "fire-speed");
        moveSpeed=125;

        buildMap = true;
        singlePlayerMode = reader->getFieldValueAsBool("Debug", "singleplayer");
        if (buildMap)
            mapFileName = reader->getFieldValueAsString("MapSettings", "map-file-name");
        if (mapPath == "NULL")
            mapPath = "Map/";
        else
            mapPath = mapPath.find("/") == std::string::npos ? mapPath.substr(mapPath.find("/")) : mapPath;
		
        gameStarted = teamDM = gameLoaded=false;

        initializeLogger(gameLogFile);
        logger->addLine("game config file " + gameConfigFile + " loaded to memory & logger initialized");
		LogManager* logManager=new LogManager();
		logManager->createLog(ogreLogFile,true,false,false);
        root = OGRE_NEW Root(pluginsConfig,ogreConfig, "");
        ConfigFile configFile;
        configFile.load(resourcesConfig);

        //[start]taken from ogre framework
        Ogre::ConfigFile::SectionIterator seci = configFile.getSectionIterator();
        Ogre::String secName, typeName, archName;
        while (seci.hasMoreElements())
        {
            secName = seci.peekNextKey();
            Ogre::ConfigFile::SettingsMultiMap *settings = seci.getNext();
            Ogre::ConfigFile::SettingsMultiMap::iterator i;
            for (i = settings->begin(); i != settings->end(); ++i)
            {
                typeName = i->first;
                archName = i->second;
                Ogre::ResourceGroupManager::getSingleton().addResourceLocation(
                    archName, typeName, secName);
			}
        }
        //[END]

            logger->addLine("ogre configuration has been read");
        root->showConfigDialog();
        renderWindow=root->initialise(true,"Team-Two");
            logger->addLine("window created");
        sceneManager=root->createSceneManager(ST_EXTERIOR_FAR,"core");
        localPlayer=NULL;
        mapMode=false;



        mainCamera=sceneManager->createCamera("MainCam");
        
        mainCamera->setNearClipDistance(1);mainCamera->setLodBias(2);
        mainCamera->setFarClipDistance(100000000);
        mainCamera->setAspectRatio(renderWindow->getWidth()/(float)renderWindow->getHeight());


        menuSceneManager=root->createSceneManager(ST_GENERIC,"menu");
        menuCamera=menuSceneManager->createCamera("MenuCam");
        menuCamera->setNearClipDistance(1);
        menuMode=true;


        viewPort=renderWindow->addViewport(mainCamera);
        dynamics=NULL;


        if(shadowsEnabled)
            sceneManager->setShadowTechnique(Ogre::SHADOWTYPE_STENCIL_ADDITIVE);
        else
            sceneManager->setShadowTechnique(Ogre::SHADOWTYPE_NONE);

        ResourceGroupManager::getSingletonPtr()->initialiseAllResourceGroups();

		logger->addLine("GameCore: scanning map files");
        lookupMapFiles(mapPath);
		logger->addLine("GameCore: --ok");
		logger->addLine("GameCore: initializing event listeners");
        initializeEventListeners();
		logger->addLine("GameCore: --ok");
		logger->addLine("GameCore: initializing CEGUI");
        initializeCEGUI();
		logger->addLine("GameCore: --ok");
		logger->addLine("GameCore: initializing menu");
        initializeMenu();
		menuController->showLoading();	
		root->renderOneFrame();
#if WINDOWS_PLATFORM
		//Sleep(5000);
#else 
		sleep(5);
#endif
		logger->addLine("GameCore: --ok");	
		logger->addLine("GameCore: initializing ingamemenu");
		initializeInGameGUI();
		logger->addLine("GameCore: --ok");	
		logger->addLine("GameCore: initializing networking");
        initializeNetworking();
		logger->addLine("GameCore: --ok");

        //=================================================DEBUG
        if (singlePlayerMode)
        {
            initializePhysics();
            logger->addLine("Physics initialized");
            initializeScene();
            logger->addLine("Scene initialized");
            if (buildMap)
                initializeMap(mapPath + mapFileName);
            logger->addLine("Map initialized");
            _initializeSinglePlayer();
            initializeItems();
            initializeTeleporters();

        }
             
         //=================================================
		logger->addLine("GameCore: initializing sounds");
        initializeSounds();
		logger->addLine("GameCore: --ok");
		root->addFrameListener(this);
        logger->addLine("GameLoop starting...");
		menuController->hideLoading();
        gameLoop();
    }
    else
        std::cout<<"configuration file not found!...\n";
}