Пример #1
0
bool AppWaterdemo2::Application()
{
  iObjectRegistry* r = GetObjectRegistry();

  // Open the main system. This will open all the previously loaded plugins
  // (i.e. all windows will be opened).
  if (!OpenApplication(r))
    return ReportError("Error opening system!");

  // Now get the pointer to various modules we need.  We fetch them from the
  // object registry.  The RequestPlugins() call we did earlier registered all
  // loaded plugins with the object registry.  It is also possible to load
  // plugins manually on-demand.
  g3d = csQueryRegistry<iGraphics3D> (r);
  if (!g3d)
    return ReportError("Failed to locate 3D renderer!");

  engine = csQueryRegistry<iEngine> (r);
  if (!engine)
    return ReportError("Failed to locate 3D engine!");
    
  vc = csQueryRegistry<iVirtualClock> (r);
  if (!vc) return ReportError("Failed to locate Virtual Clock!");

  kbd = csQueryRegistry<iKeyboardDriver> (r);
  if (!kbd) return ReportError("Failed to locate Keyboard Driver!");

  loader = csQueryRegistry<iLoader> (r);
  if (!loader) return ReportError("Failed to locate Loader!");
  
  rotY = 0;
  rotX = 0;

  if(!LoadMap()) return 0;
	
  room = engine->FindSector ("room");

  engine->Prepare ();

  view.AttachNew(new csView (engine, g3d));
  iGraphics2D* g2d = g3d->GetDriver2D ();
  view->SetRectangle (0, 0, g2d->GetWidth (), g2d->GetHeight ());

  view->GetCamera ()->SetSector (room);
  view->GetCamera ()->GetTransform ().SetOrigin (csVector3 (0, 3, 0));
  
  printer.AttachNew (new FramePrinter (GetObjectRegistry ()));

  //****************** END OF INITIALIZATION STUFFS ***********************//
  // Start the default run/event loop.  This will return only when some code,
  // such as OnKeyboard(), has asked the run loop to terminate.
  Run();

  return true;
}
Пример #2
0
bool EventTest::Application()
{
  // Open the main system. This will open all the previously loaded plug-ins.
  // i.e. all windows will be opened.
  if (!OpenApplication(GetObjectRegistry()))
    return ReportError("Error opening system!");

  Run();

  return true;
}
Пример #3
0
bool Simple::Application()
{
  // Open the main system. This will open all the previously loaded plug-ins.
  // i.e. all windows will be opened.
  if (!OpenApplication(GetObjectRegistry()))
    return ReportError("Error opening system!");

  if (SetupModules())
  {
    // This calls the default runloop. This will basically just keep
    // broadcasting process events to keep the game going.
    Run();
  }

  return true;
}
Пример #4
0
bool StartMe::Application()
{
  // Set up window transparency. Must happen _before_ system is opened!
  csRef<iGraphics2D> g2d = csQueryRegistry<iGraphics2D> (GetObjectRegistry ());
  if (!g2d) return ReportError ("Failed to obtain canvas!");
  natwin = scfQueryInterface<iNativeWindow> (g2d);
  if (natwin)
  {
    natwin->SetWindowTransparent (true);
  }

  // Open the main system. This will open all the previously loaded plug-ins.
  // i.e. all windows will be opened.
  if (!OpenApplication(GetObjectRegistry()))
    return ReportError("Error opening system!");

  // The window is open, so lets make it disappear! 
  if (natwin)
  {
    natwin->SetWindowDecoration (iNativeWindow::decoCaption, false);
    natwin->SetWindowDecoration (iNativeWindow::decoClientFrame, false);
  }

  // Now get the pointer to various modules we need. We fetch them
  // from the object registry. The RequestPlugins() call we did earlier
  // registered all loaded plugins with the object registry.
  g3d = csQueryRegistry<iGraphics3D> (GetObjectRegistry());
  if (!g3d) return ReportError("Failed to locate 3D renderer!");

  engine = csQueryRegistry<iEngine> (GetObjectRegistry());
  if (!engine) return ReportError("Failed to locate 3D engine!");

  vc = csQueryRegistry<iVirtualClock> (GetObjectRegistry());
  if (!vc) return ReportError("Failed to locate Virtual Clock!");

  kbd = csQueryRegistry<iKeyboardDriver> (GetObjectRegistry());
  if (!kbd) return ReportError("Failed to locate Keyboard Driver!");

  loader = csQueryRegistry<iLoader> (GetObjectRegistry());
  if (!loader) return ReportError("Failed to locate Loader!");

  vfs = csQueryRegistry<iVFS> (GetObjectRegistry());
  if (!vfs) return ReportError("Failed to locate VFS!");

  confman = csQueryRegistry<iConfigManager> (GetObjectRegistry());
  if (!confman) return ReportError("Failed to locate Config Manager!");

  cegui = csQueryRegistry<iCEGUI> (GetObjectRegistry());
  if (!cegui) return ReportError("Failed to locate CEGUI plugin");

  // Initialize the CEGUI wrapper
  cegui->Initialize ();
  
  // Let the CEGUI plugin take care of the rendering by itself
  cegui->SetAutoRender (true);
  
  // Set the logging level
  cegui->GetLoggerPtr ()->setLoggingLevel(CEGUI::Informative);

  vfs->ChDir ("/cegui/");

  // Load the 'ice' skin (which uses the Falagard skinning system)
  cegui->GetSchemeManagerPtr ()->create("ice.scheme");

  cegui->GetSystemPtr ()->setDefaultMouseCursor("ice", "MouseArrow");

  // Setup the fonts
  cegui->GetFontManagerPtr ()->createFreeTypeFont
    (FONT_NORMAL, 10, true, "/fonts/ttf/DejaVuSerif.ttf");
  cegui->GetFontManagerPtr ()->createFreeTypeFont
    (FONT_NORMAL_ITALIC, 10, true, "/fonts/ttf/DejaVuSerif-Italic.ttf");
  cegui->GetFontManagerPtr ()->createFreeTypeFont
    (FONT_TITLE, 15, true, "/fonts/ttf/DejaVuSerif-Bold.ttf");
  cegui->GetFontManagerPtr ()->createFreeTypeFont
    (FONT_TITLE_ITALIC, 15, true, "/fonts/ttf/DejaVuSerif-BoldItalic.ttf");

  CEGUI::WindowManager* winMgr = cegui->GetWindowManagerPtr ();

  // Load the CEGUI layout and set it as the root layout
  vfs->ChDir ("/data/startme/");
  cegui->GetSchemeManagerPtr ()->create ("crystal.scheme");
  cegui->GetSystemPtr ()->setGUISheet(winMgr->loadWindowLayout ("startme.layout"));

  // We need a View to the virtual world.
  view.AttachNew (new csView (engine, g3d));

  LoadConfig ();

  CEGUI::Window* logo = winMgr->getWindow("Logo");
  logo->subscribeEvent(CEGUI::Window::EventMouseClick,
      CEGUI::Event::Subscriber(&StartMe::OnLogoClicked, this));

  ///TODO: Using 'EventMouseEntersArea' is more correct but is only available 
  /// in 0.7.2+
  logo->subscribeEvent(CEGUI::Window::EventMouseEnters,
      CEGUI::Event::Subscriber(&StartMe::OnEnterLogo, this));
  logo->subscribeEvent(CEGUI::Window::EventMouseLeaves,
      CEGUI::Event::Subscriber(&StartMe::OnLeaveLogo, this));

  vfs->ChDir ("/lib/startme");

  CEGUI::Window* root = winMgr->getWindow("root");

  for (size_t i = 0 ; i < demos.GetSize () ; i++)
  {
    demos[i].window = winMgr->createWindow("crystal/Icon");
    demos[i].window->setSize(CEGUI::UVector2(CEGUI::UDim(0.0f, 128.0f), CEGUI::UDim(0.0f, 128.0f)));
    demos[i].window->setPosition(CEGUI::UVector2(CEGUI::UDim(0.0f, 0.0f), CEGUI::UDim(0.0f, 0.0f)));
    demos[i].window->setVisible(false);

    CEGUI::ImagesetManager* imsetmgr = cegui->GetImagesetManagerPtr();
    if (!imsetmgr->isDefined(demos[i].image))
      imsetmgr->createFromImageFile(demos[i].image, demos[i].image);
    std::string img = "set:"+std::string(demos[i].image)+" image:full_image";
    demos[i].window->setProperty("Image", img);

    root->addChildWindow(demos[i].window);

    demos[i].window->subscribeEvent(CEGUI::Window::EventMouseClick,
      CEGUI::Event::Subscriber(&StartMe::OnClick, this));
  }

  // Initialize the starting position of the demo wheel to a random value
  csRandomFloatGen frandomGenerator;
  position = frandomGenerator.Get (demos.GetSize () - 1);

  // Let the engine prepare everything
  engine->Prepare ();
  printer.AttachNew (new FramePrinter (object_reg));

  // This calls the default runloop. This will basically just keep
  // broadcasting process events to keep the application going on.
  Run();

  return true;
}
Пример #5
0
BOOL KappaCommand(HWND hWnd, unsigned message, WORD wParam, long lParam)
{
    char stCommand[RET_BUFFER_LEN];

    switch (message) {
      case IDM_NEW:
          if (in_wait_for_input)
              return FALSE;
#ifndef RUNTIME
          if (lpKALView && (*lpKALView->Terminate)())
          {
              PostMessage(hWndKappa, WM_COMMAND, IDM_NEW, 0L);
              return FALSE;
          }
#endif
          KppNewApplication(hInstKappa);

#ifdef RUNTIME
          if (!IsWindowVisible(hWnd) && !KppGetCompiledKALInit())
              ShowWindow(hWnd, SW_SHOWNORMAL);
#endif
          break;

      case IDM_NEWLOAD:
          if (in_wait_for_input)
              return FALSE;
          if (LOWORD(lParam))
              KppSetAppChanged(FALSE);
          if (KppNewApplication(hInstKappa) && lParam)
          {
              GlobalGetAtomName(HIWORD(lParam), stCommand, RET_BUFFER_LEN);
                
#ifdef RUNTIME
              {
                  BOOL bNoShow = ProcessCmdLine(stCommand, 
                                                KppIsMultiEnabled());

                  if (!IsWindowVisible(hWnd) && !bNoShow)
                      ShowWindow(hWnd, SW_SHOWNORMAL);
              }
#else
              ProcessCmdLine(stCommand, KppIsMultiEnabled());
#endif
                    
              GlobalDeleteAtom(HIWORD(lParam));
          }
          break;

      case IDM_OPEN:
          OpenApplication(hWnd);
          break;

#ifndef LIMITED
      case IDM_SAVE:
          SaveApplication(hWnd, SAVE_MODE);
          break;

      case IDM_SAVEAS:
          SaveApplicationAs(hWnd);
          break;
#endif
          
      case IDM_SETUPPRINT:
          ConfigurePrinter();
          break;

      case IDM_EXIT:
          if (in_wait_for_input)
              return FALSE;
                
#ifdef RUNTIME
          if (hWnd != KpsGetMainSessionWindow())
          {
              ATOMID idWind = KpsGetWidgetFromWindow(hWnd);
                
              if (idWind)
                  kpc_hide_window(idWind, hWnd);
              break;
          }
#endif
          /* Postpone closing down until all DDE messages have *
           * been processed.                                   */
          if (KppDDEPendingQCB())
          {
              WaitForInputCB();
              PostMessage(hWnd, WM_COMMAND, message, lParam);
              return FALSE;
          }

#ifndef RUNTIME
          if (lpKALView && (*lpKALView->Terminate)())
          {
              PostMessage(hWnd, WM_COMMAND, IDM_EXIT, 0L);
              return FALSE;
          }
#endif
          if (lParam == kEXIT_NOPROMPT)
              MarkAppAsUnmodifiedCB();
          return KappaClose(hWnd);

      case IDM_ABOUT:
          KappaAbout(hWnd);
          break;
          
#ifndef RUNTIME
      case IDM_HELP:
          KppDoWindowHelp(hWndKappa, "d_main");
          break;
#endif

      case IDM_ONLINEHELP:
      {
          HANDLE hKapHelp = GetModuleHandle("KAPHELP");
          LPHELPFN lpfnKappaHelp = 
              (LPHELPFN) GetProcAddress(hKapHelp, "KppKappaHelp");
          
          if (lpfnKappaHelp)
              (*lpfnKappaHelp)(hWndKappa, hInstKappa);
          break;
      }

#ifndef RUNTIME
      case IDM_UNDO:
      case IDM_CUT:
      case IDM_COPY:
      case IDM_PASTE:
      case IDM_CLEAR:
          EditControlCommand(hWnd, hWndComment, message, wParam, lParam);
          break;

      case IDM_RESET:
          ClearEditWindow(hWndInterpret);
          SendMessage(hWndInterpret, IDG_UPDATEINDEX, 1, 0L);
          break;

      case IDM_KTOOLS:
#ifdef EDITORS
          KappaKToolsMode(bKToolsMode != TRUE, SW_SHOWNORMAL);
#endif
          break;
#endif
        
      case IDM_BROWSER:
          KappaBrowserMode(bBrowserMode != TRUE, SW_SHOWNORMAL);
          break;

#ifndef RUNTIME
#ifdef INFERENCE
      case IDM_INFERENCE:
          KappaInferenceMode(bInferenceMode != TRUE, SW_SHOWNORMAL);
          break;

      case IDM_RULEREL:
          KappaRuleRelMode(!bRuleRelMode, SW_SHOWNORMAL);
          break;

      case IDM_TRACE:
          KappaTraceMode(bTraceMode != TRUE, SW_SHOWNORMAL);
          break;
#endif

      case IDM_EDITORS:
          AllEditorWnds();
          break;

      case IDM_KAL:
          KappaInterpMode(!bInterpMode, SW_SHOWNORMAL);
          break;

      case IDM_FINDER:
          KappaFinderMode(!bFinderMode, SW_SHOWNORMAL);
          break;

      case IDM_KALVIEW:
          if (lpKALView)
              (*lpKALView->KALView)(!lpKALView->bKALViewMode,
                                    SW_SHOWNORMAL, 
                                    hWndKappa, hInstKappa, kalviewIcon);
          break;

      case IDM_SESSION:
          KpsAllSessionWnd();
          break;
          
      case IDM_COMMENT:
          bCommentShown = !bCommentShown;
          ShowComment(hWnd, bCommentShown);
          break;
#endif
          
      case IDM_ENTERDEBUGGER:
          DebugBreak();
          break;

      default:
          break;
    }

    return TRUE;
}
Пример #6
0
bool AvatarTest::Application ()
{
  if (!OpenApplication (GetObjectRegistry ()))
    return ReportError ("Error opening system!");

  g3d = csQueryRegistry<iGraphics3D> (GetObjectRegistry ());
  if (!g3d) return ReportError("Failed to locate 3D renderer!");

  engine = csQueryRegistry<iEngine> (GetObjectRegistry ());
  if (!engine) return ReportError("Failed to locate 3D engine!");

  vc = csQueryRegistry<iVirtualClock> (GetObjectRegistry ());
  if (!vc) return ReportError("Failed to locate Virtual Clock!");

  kbd = csQueryRegistry<iKeyboardDriver> (GetObjectRegistry ());
  if (!kbd) return ReportError("Failed to locate Keyboard Driver!");

  loader = csQueryRegistry<iLoader> (GetObjectRegistry ());
  if (!loader) return ReportError("Failed to locate Loader!");

  g2d = csQueryRegistry<iGraphics2D> (GetObjectRegistry ());
  if (!g2d) return ReportError("Failed to locate 2D renderer!");

  lookAtManager = csQueryRegistry<iSkeletonLookAtManager2> (GetObjectRegistry ());
  if (!lookAtManager) return ReportError("Failed to locate iLookAtManager plugin!");

  basicNodesManager =
    csQueryRegistry<iSkeletonBasicNodesManager2> (GetObjectRegistry ());
  if (!basicNodesManager)
    return ReportError("Failed to locate iSkeletonBasicNodesManager2 plugin!");

  printer.AttachNew (new FramePrinter (GetObjectRegistry ()));

  csRef<iFontServer> fs = g3d->GetDriver2D()->GetFontServer ();
  if (fs)
    courierFont = fs->LoadFont (CSFONT_COURIER);
  else return ReportError ("Failed to locate font server!");

  // Create the dynamic system
  if (physicsEnabled)
  {
    dynamicSystem = dynamics->CreateSystem ();
    if (!dynamicSystem) 
    {
      ReportWarning
	("Can't create dynamic system, continuing with reduced functionalities");
      physicsEnabled = false;
    }

    else
    {
      // Load the ragdoll plugin
      csRef<iPluginManager> plugmgr = 
	csQueryRegistry<iPluginManager> (GetObjectRegistry ());
      ragdollManager = csLoadPlugin<iSkeletonRagdollManager2>
	(plugmgr, "crystalspace.mesh.animesh.controllers.ragdoll");
      if (!ragdollManager)
      {
	ReportWarning
	  ("Can't load ragdoll plugin, continuing with reduced functionalities");
	physicsEnabled = false;
      }
    }
  }

  // Create sector
  room = engine->CreateSector ("room");

  // Initialize camera
  view = csPtr<iView> (new csView (engine, g3d));
  view->GetCamera ()->SetSector (room);
  iGraphics2D* g2d = g3d->GetDriver2D ();
  view->SetRectangle (0, 0, g2d->GetWidth (), g2d->GetHeight ());

  // Create scene
  CreateRoom ();

  // Create avatar
  if (avatarModel == MODEL_KRYSTAL)
    avatarScene = new KrystalScene (this);
  else
    avatarScene = new FrankieScene (this);
  if (!avatarScene->CreateAvatar ())
    return false;

  // Initialize camera position
  view->GetCamera ()->GetTransform ().SetOrigin (avatarScene->GetCameraStart ());

  // Run the application
  Run();

  return true;
}