diff --git a/tutorials/gui/games.C b/tutorials/gui/games.C index 80b21e91f9f2de4904f8feae468b7075cd53e0cc..4aaf1b04425791407cb7d7b7189a60b6ec1afd9f 100644 --- a/tutorials/gui/games.C +++ b/tutorials/gui/games.C @@ -2,7 +2,49 @@ void games() { - Error("games", "Must be called from run_games.C..."); + TString dir = gSystem->UnixPathName(gInterpreter->GetCurrentMacroName()); + dir.ReplaceAll("games.C",""); + dir.ReplaceAll("/./","/"); + gSystem->Load("libGui"); + Bool_t UNIX = strcmp(gSystem->GetName(), "Unix") == 0; + Int_t st1 = gSystem->Load("$(ROOTSYS)/test/Aclock"); + if (st1 == -1) { + printf("===>The macro games will try to build the Aclock library\n"); + if (UNIX) + gSystem->Exec("(cd $ROOTSYS/test; make Aclock)"); + else + gSystem->Exec("(cd %ROOTSYS%\\test && nmake -f Makefile.win32 Aclock.dll)"); + + st1 = gSystem->Load("$(ROOTSYS)/test/Aclock"); + } + Int_t st2 = gSystem->Load("$(ROOTSYS)/test/Hello"); + if (st2 == -1) { + printf("===>The macro games will try to build the Hello library\n"); + if (UNIX) + gSystem->Exec("(cd $ROOTSYS/test; make Hello)"); + else + gSystem->Exec("(cd %ROOTSYS%\\test && nmake -f Makefile.win32 Hello.dll)"); + + st2 = gSystem->Load("$(ROOTSYS)/test/Hello"); + } + Int_t st3 = gSystem->Load("$(ROOTSYS)/test/Tetris"); + if (st3 == -1) { + if (UNIX) { + printf("===>The macro games will try to build the Tetris library\n"); + gSystem->Exec("(cd $ROOTSYS/test; make Tetris)"); + } else { + gSystem->Exec("(cd %ROOTSYS%\\test && nmake -f Makefile.win32 Tetris.dll)"); + } + st3 = gSystem->Load("$(ROOTSYS)/test/Tetris"); + } + if (st1 || st2 || st3) { + printf("ERROR: one of the shared libs in $ROOTSYS/test didn't load properly\n"); + return; + } + gROOT->ProcessLine("#define __RUN_GAMES__ 1"); + gROOT->ProcessLine("#include \"games.C\""); + gROOT->ProcessLine("rungames()"); + gROOT->ProcessLine("#undef __RUN_GAMES__"); } #else @@ -11,7 +53,7 @@ class Hello; class Aclock; class Tetris; -void games() +void rungames() { // This macro runs three "games" that each nicely illustrate the graphics capabilities of ROOT. // Thanks to the clever usage of TTimer objects it looks like they are all diff --git a/tutorials/gui/run_games.C b/tutorials/gui/run_games.C deleted file mode 100644 index ac5b8183b2d3fee2f13d18d0733750b9dcf615f7..0000000000000000000000000000000000000000 --- a/tutorials/gui/run_games.C +++ /dev/null @@ -1,44 +0,0 @@ -// Macro used to prepare the environment before running the games.C macro - -void run_games() -{ - gSystem->Load("libGui"); - Bool_t UNIX = strcmp(gSystem->GetName(), "Unix") == 0; - Int_t st1 = gSystem->Load("$(ROOTSYS)/test/Aclock"); - if (st1 == -1) { - printf("===>The macro games will try to build the Aclock library\n"); - if (UNIX) - gSystem->Exec("(cd $ROOTSYS/test; make Aclock)"); - else - gSystem->Exec("(cd %ROOTSYS%\\test && nmake -f Makefile.win32 Aclock.dll)"); - - st1 = gSystem->Load("$(ROOTSYS)/test/Aclock"); - } - Int_t st2 = gSystem->Load("$(ROOTSYS)/test/Hello"); - if (st2 == -1) { - printf("===>The macro games will try to build the Hello library\n"); - if (UNIX) - gSystem->Exec("(cd $ROOTSYS/test; make Hello)"); - else - gSystem->Exec("(cd %ROOTSYS%\\test && nmake -f Makefile.win32 Hello.dll)"); - - st2 = gSystem->Load("$(ROOTSYS)/test/Hello"); - } - Int_t st3 = gSystem->Load("$(ROOTSYS)/test/Tetris"); - if (st3 == -1) { - if (UNIX) { - printf("===>The macro games will try to build the Tetris library\n"); - gSystem->Exec("(cd $ROOTSYS/test; make Tetris)"); - } else { - gSystem->Exec("(cd %ROOTSYS%\\test && nmake -f Makefile.win32 Tetris.dll)"); - } - st3 = gSystem->Load("$(ROOTSYS)/test/Tetris"); - } - if (st1 || st2 || st3) { - printf("ERROR: one of the shared libs in $ROOTSYS/test didn't load properly\n"); - return; - } - gROOT->ProcessLine("#define __RUN_GAMES__ 1"); - gInterpreter->ExecuteMacro("games.C"); - gROOT->ProcessLine("#undef __RUN_GAMES__"); -}