//----------------------------------------------------------------------- bool Root::showConfigDialog(void) { // Displays the standard config dialog // Will use stored defaults if available ConfigDialog* dlg; bool isOk; restoreConfig(); dlg = OGRE_NEW ConfigDialog(); if ((isOk = dlg->display())) saveConfig(); OGRE_DELETE dlg; return isOk; }
sBool sAppHandler(sInt code,sDInt value) { static const sInt aspectRatios[][2] = { { 4,3 }, { 5,4 }, { 16,9 }, { 16,10 }, { 2,1 } }; sInt beat; static sU8 *data; sViewport vp,clearvp; sInt i,max; sF32 curfps; static sF32 oldfps; static sInt FirstTime,ThisTime,LastTime; static sInt framectr=0; sRect r; sInt targetHeight; KOp *root; //GenBitmapTextureSizeOffset = -1; switch(code) { case sAPPCODE_CONFIG: data = PtrTable[0]; //#if !sINTRO if(((sInt)data)==0x54525450) { data = sSystem->LoadFile(sSystem->GetCmdLine()); if(data==0) { data = sSystem->LoadFile("bpopening_05.kx"); if(data==0) sSystem->Abort("need data file"); } } //#endif #if sCONFIGDIALOG { sChar *name = 0; if(data[0]&1) name = (sChar *)(data+4); return ConfigDialog(101,name) == 1; } #endif break; case sAPPCODE_INIT: Document = new KDoc; Document->Init(data); Environment = new KEnvironment; Sound = 0; sInitPerlin(); GenOverlayInit(); RenderTargetManager = new RenderTargetManager_; Engine = new Engine_; #if sLINK_KKRIEGER Game = new KKriegerGame; Game->Init(); #else Game = 0; #endif sFloatFix(); i = sSystem->GetTime(); Environment->Splines = &Document->Splines.Array; Environment->SplineCount = Document->Splines.Count; Environment->Game = Game; Environment->InitView(); Environment->InitFrame(0,0); Document->Precalc(Environment); Environment->ExitFrame(); #if WAITFORKEY sSystem->WaitForKey(); #endif if(Document->SongSize) { #if sINTRO Sound = new CV2MPlayer; #if sLINK_KKRIEGER if(Document->SampleSize) RenderSoundEffects(Document,Document->SampleData); #endif Sound->Open(Document->SongData); Sound->Play(0); SoundTimer = 0; sSystem->SetSoundHandler(IntroSoundHandler,64); #else Player = new sOGGDecoder; Player->Load(Document->SongData,Document->SongSize); Player->Start(0); sSystem->SetSoundHandler(MusicPlayerHandler,64,Player); #endif } #if sLINK_KKRIEGER Game->ResetRoot(Environment,Document->RootOps[Document->CurrentRoot],1); #endif FirstTime = sSystem->GetTime(); LastTime = 0; oldfps = 0.0f; sDPrintF("%d bytes of texture memory used\n",DebugTexMem); break; #if !sINTRO case sAPPCODE_EXIT: sSystem->SetSoundHandler(0,0,0); if(Sound) { CV2MPlayer *old; old = Sound; Sound = 0; delete old; } delete Player; delete Environment; #if sLINK_KKRIEGER Game->Exit(); delete Game; #endif Document->Exit(); delete Document; delete RenderTargetManager; delete Engine; GenOverlayExit(); break; #endif case sAPPCODE_PAINT: // tick processing (moved up to reduce input lag by 1 frame) ThisTime = sSystem->GetTime() - FirstTime; #if sLINK_KKRIEGER beat = sMulDiv(ThisTime,Document->SongBPM,60000); #else if(Document->BuzzTiming) { sInt sample; sample = Document->SongSize ? sSystem->GetCurrentSample() : sMulDiv(ThisTime,44100,1000); beat = sDivShift(sample,60*44100/((Document->SongBPM>>16)*8)) / 8; } else
sBool sAppHandler(sInt code,sDInt value) { sInt beat; static const sU8 *data; sViewport vp,clearvp; sInt i,max; sF32 curfps; static sF32 oldfps; static sInt FirstTime,ThisTime,LastTime; static sInt framectr=0; sRect r; KOp *root; switch(code) { case sAPPCODE_CONFIG: #if !LINKEDIN data = PtrTable[0]; //#if !sINTRO if(((sInt)data)==0x54525450) { data = sSystem->LoadFile(sSystem->GetCmdLine()); if(data==0) { data = sSystem->LoadFile("id08.kx"); if(data==0) sSystem->Abort("need data file"); } } //#endif #else data = DebugData; #endif #if sCONFIGDIALOG { sChar *name = 0; if(data[0]&1) name = (sChar *)(data+4); return ConfigDialog(101,name) == 1; } #endif break; case sAPPCODE_INIT: #if !sCONFIGDIALOG #if !LINKEDIN data = PtrTable[0]; if(((sInt)data)==0x54525450) { data = sSystem->LoadFile(sSystem->GetCmdLine()); if(!data) sFatal("need data file"); } #else data = DebugData; #endif #endif Document = new KDoc; Document->Init(data); Environment = new KEnvironment; Sound = 0; // low texture size: only for texture quality setting "normal" GenBitmapTextureSizeOffset = (IntroTexQuality >= 1) ? 0 : -1; GenBitmapDefaultFormat = (IntroTexQuality >= 2) ? sTF_A8R8G8B8 : sTF_DXT1; sInitPerlin(); // determine render viewport vp.Init(); DetermineTargetViewport(vp); RenderTargetManager = new RenderTargetManager_; RenderTargetManager->SetMasterViewport(vp); // preallocate some rendertargets Engine = new Engine_; RenderTargetManager->Add(0x00010000,0,0); RenderTargetManager->Add(0x00020010,512,256); // glare temp 1 RenderTargetManager->Add(0x00020011,256,128); // glare temp 2 GenOverlayInit(); GenOverlayManager->SetMasterViewport(vp); if(!IntroShadows) Engine->SetUsageMask(~(1<<ENGU_SHADOW)); #if sLINK_KKRIEGER Game = new KKriegerGame; Game->Init(); #else Game = 0; #endif #if LOADERTUNE // start loader tune Player = new sViruz2; Player->Load(LoaderTune,LoaderTuneSize); Player->Start(0); sSystem->SetSoundHandler(MusicPlayerHandler,SOUNDALIGN,Player); #endif sFloatFix(); i = sSystem->GetTime(); Environment->Splines = &Document->Splines.Array; Environment->SplineCount = Document->Splines.Count; Environment->Game = Game; Environment->InitView(); Environment->InitFrame(0,0); Document->Precalc(Environment); Environment->ExitFrame(); // stop loader tune #if LOADERTUNE sSystem->SetSoundHandler(0,0,0); delete Player; Player = 0; #endif #if WAITFORKEY sSystem->WaitForKey(); #endif if(Document->SongSize) { #if sINTRO Sound = new CV2MPlayer; #if sLINK_KKRIEGER if(Document->SampleSize) RenderSoundEffects(Document,Document->SampleData); #endif Sound->Init(); Sound->Open(Document->SongData); Sound->Play(0); SoundTimer = 0; sSystem->SetSoundHandler(IntroSoundHandler,SOUNDALIGN); #else // !sINTRO #if sLINK_OGG Player = new sOGGDecoder; #else Player = new sViruz2; #endif Player->Load(Document->SongData,Document->SongSize); Player->Start(0); sSystem->SetSoundHandler(MusicPlayerHandler,SOUNDALIGN,Player); #endif } #if sLINK_KKRIEGER Game->ResetRoot(Environment,Document->RootOps[Document->CurrentRoot],1); #endif FirstTime = sSystem->GetTime(); LastTime = 0; oldfps = 0.0f; #if sNOCRT sDPrintF("memory allocated: %d bytes\n",MallocSize); #endif break; #if !sINTRO case sAPPCODE_EXIT: sSystem->SetSoundHandler(0,0,0); if(Sound) { CV2MPlayer *old; old = Sound; Sound = 0; delete old; } delete Player; delete Environment; #if sLINK_KKRIEGER Game->Exit(); delete Game; #endif Document->Exit(); delete Document; delete RenderTargetManager; delete Engine; GenOverlayExit(); break; #endif case sAPPCODE_PAINT: // tick processing (moved up to reduce input lag by 1 frame) ThisTime = sSystem->GetTime() - FirstTime; #if sLINK_KKRIEGER beat = sMulDiv(ThisTime,Document->SongBPM,60000); #else if(Document->BuzzTiming) { sInt sample; sample = Document->SongSize ? sSystem->GetCurrentSample() : sMulDiv(ThisTime,44100,1000); beat = sDivShift(sample,60*44100/((Document->SongBPM>>16)*8)) / 8; } else
bool config_dialog(Options& options) { return ConfigDialog(options).show(); }