예제 #1
0
void Workarea::resize()
{
  Render *render = RenderSystem::getInstance().getRenderer();
  int width = render->getWindowWidth(),
      height = render->getWindowHeight();
  m_graphics->setTargetPlane(width, height);
  m_top->resize(width, height, m_width, m_height);
  // m_top->setDimension(gcn::Rectangle(0, 0, width, height));
  m_width = width;
  m_height = height;
}
예제 #2
0
void Workarea::init()
{
  m_imageLoader = new gcn::OpenGLSDLImageLoader();

  // Set the loader that the OpenGLImageLoader should use to load images from
  // disk, as it can't do it itself, and then install the image loader into
  // guichan.
  gcn::Image::setImageLoader(m_imageLoader);

  // Create the handler for OpenGL graphics.
  m_graphics = new gcn::OpenGLGraphics();

  // Tell it the size of our screen.
  Render * render = RenderSystem::getInstance().getRenderer();
  m_width = render->getWindowWidth();
  m_height = render->getWindowHeight();
  m_graphics->setTargetPlane(m_width, m_height);

  m_input = new gcn::SDLInput();

  m_top = new RootWidget();
  m_top->setDimension(gcn::Rectangle(0, 0, m_width, m_height));
  m_top->setOpaque(false);
  m_top->setFocusable(true);
  m_top->setTabInEnabled(false);

  m_gui = new Gui();
  m_gui->setGraphics(m_graphics);
  m_gui->setInput(m_input);
  m_gui->setTop(m_top);

  try {
    std::string font_path = m_fixed_font;
    m_system->getFileHandler()->getFilePath(font_path);

    gcn::ImageFontXPM * font = new gcn::ImageFontXPM("default_font", rpgfont_xpm, m_fixed_font_characters);
    
    gcn::Widget::setGlobalFont(font);
  } catch (...) {
    std::cerr << "Failed to load font " << m_fixed_font << std::endl << std::flush;
  }

  gcn::Window* con_w = new ConnectWindow();
  m_top->add(con_w, m_width / 2 - con_w->getWidth() / 2, m_height / 2 - con_w->getHeight () / 2);

  m_panel = new Panel(m_top);
  // m_top->add(m_panel, 0, 0);
  m_top->setWindowCoords(m_panel, std::make_pair(0,0));
  m_windows["panel"] = m_panel;

  m_windows["connect"] = con_w;
  m_windows["login"] = new LoginWindow();
  m_windows["character"] = new CharacterWindow();
  m_windows["update"] = new WFUTWindow();
  m_windows["compass"] = new Compass();

  m_system->getActionHandler()->addHandler("connected", "/workarea_close connect");
  m_system->getActionHandler()->addHandler("connected", "/workarea_open login");
  m_system->getActionHandler()->addHandler("disconnected", "/workarea_alert Connection to server failed");
  m_system->getActionHandler()->addHandler("disconnected", "/workarea_open connect");

  m_system->getActionHandler()->addHandler("logged_in", "/workarea_close login");
  m_system->getActionHandler()->addHandler("logged_in", "/workarea_open character");

  m_system->getActionHandler()->addHandler("world_entered", "/workarea_close character");
  m_system->getActionHandler()->addHandler("world_entered", "/workarea_open panel");
  m_system->getActionHandler()->addHandler("avatar_failed", "/workarea_alert Unable to get character");

  m_system->getActionHandler()->addHandler("inventory_open", "/panel_toggle Inventory");

  RenderSystem::getInstance().ContextCreated.connect(sigc::mem_fun(*this, &Workarea::contextCreated));
  RenderSystem::getInstance().ContextDestroyed.connect(sigc::mem_fun(*this, &Workarea::contextDestroyed));
}