Esempio n. 1
0
void cProtocol132::SendWholeInventory(const cWindow & a_Window)
{
	// 1.3.2 requires player inventory slots to be sent as SetSlot packets, 
	// otherwise it sometimes fails to update the window
	
	// Send the entire window:
	super::SendWholeInventory(a_Window);
	
	// Send the player inventory and hotbar:
	cPlayer * Player = m_Client->GetPlayer();
	const cInventory & Inventory = Player->GetInventory();
	int BaseOffset = a_Window.GetNumSlots() - (cInventory::invNumSlots - cInventory::invInventoryOffset);  // Number of non-inventory slots
	char WindowID = a_Window.GetWindowID();
	for (short i = 0; i < cInventory::invInventoryCount; i++)
	{
		SendInventorySlot(WindowID, BaseOffset + i, Inventory.GetInventorySlot(i));
	}  // for i - Inventory[]
	BaseOffset += cInventory::invInventoryCount;
	for (short i = 0; i < cInventory::invHotbarCount; i++)
	{
		SendInventorySlot(WindowID, BaseOffset + i, Inventory.GetHotbarSlot(i));
	}  // for i - Hotbar[]
	
	// Send even the item being dragged:
	SendInventorySlot(-1, -1, Player->GetDraggingItem());
}
Esempio n. 2
0
void cProtocol125::SendWholeInventory(const cWindow & a_Window)
{
	cCSLock Lock(m_CSPacket);
	cItems Slots;
	a_Window.GetSlots(*(m_Client->GetPlayer()), Slots);
	SendWindowSlots(a_Window.GetWindowID(), (int)Slots.size(), &(Slots[0]));
}
Esempio n. 3
0
void cProtocol125::SendWindowClose(const cWindow & a_Window)
{
	if (a_Window.GetWindowType() == cWindow::wtInventory)
	{
		// Do not send inventory-window-close
		return;
	}
	
	cCSLock Lock(m_CSPacket);
	WriteByte(PACKET_WINDOW_CLOSE);
	WriteChar(a_Window.GetWindowID());
	Flush();
}
Esempio n. 4
0
void cProtocol125::SendWindowOpen(const cWindow & a_Window)
{
	if (a_Window.GetWindowType() < 0)
	{
		// Do not send for inventory windows
		return;
	}
	cCSLock Lock(m_CSPacket);
	WriteByte  (PACKET_WINDOW_OPEN);
	WriteChar  (a_Window.GetWindowID());
	WriteByte  ((Byte)a_Window.GetWindowType());
	WriteString(a_Window.GetWindowTitle());
	WriteByte  ((Byte)a_Window.GetNumNonInventorySlots());
	Flush();
}
Esempio n. 5
0
void cProtocol125::SendWindowProperty(const cWindow & a_Window, int a_Property, int a_Value)
{
	cCSLock Lock(m_CSPacket);
	WriteByte (PACKET_WINDOW_PROPERTY);
	WriteChar (a_Window.GetWindowID());
	WriteShort(a_Property);
	WriteShort(a_Value);
	Flush();
}
Esempio n. 6
0
  void cLinkControl::Create(cWindow& parent, cLinkControlListener& listener, int idControl, const string_t& sText)
  {
    // Create the SysLink control
    control = ::CreateWindowEx(NULL, WC_LINK, sText.c_str(),
      WS_VISIBLE | WS_CHILD | WS_TABSTOP,
      50, 220, 100, 24,
      parent.GetWindowHandle(),
      (HMENU)NULL,
      ::GetModuleHandle(NULL), NULL
    );

    // Set the default font
    parent.SetControlDefaultFont(control);

    parent.AddHandler(control, *this);

    pListener = &listener;
  }
Esempio n. 7
0
  void cImageControl::Create(cWindow& parent, const cBitmap& bitmap)
  {
    // Create the control
    control = ::CreateWindowEx(0, WC_STATIC, NULL, WS_VISIBLE | WS_CHILD | WS_CLIPSIBLINGS | SS_BITMAP, 0, 0, 0, 0, parent.GetWindowHandle(), 0, GetHInstance(), NULL);

    // Set the image
    SetImage(bitmap);

    parent.AddHandler(control, *this);
  }
Esempio n. 8
0
  void cTaskBar::Init(cWindow& owner)
  {
    std::cout<<"LTaskbarButton::Init"<<std::endl;

    ASSERT(hwndWindow == NULL);
    hwndWindow = owner.GetWindowHandle();

    ASSERT(!taskBarList.IsValid());
    taskBarList.CreateObject((REFCLSID)CLSID_TaskbarList, IID_ITaskbarList3);
    ASSERT(taskBarList.IsValid());
  }
Esempio n. 9
0
  void OpenWebPage(const cWindow& parent, const string_t& sWebPage)
  {
    // Launch this web page in the default browser
    SHELLEXECUTEINFO sh;
    memset(&sh, 0, sizeof(SHELLEXECUTEINFO));

    sh.cbSize = sizeof(SHELLEXECUTEINFO);
    sh.lpVerb = TEXT("open");
    sh.lpFile = sWebPage.c_str();
    sh.hwnd = parent.GetWindowHandle();
    sh.nShow = SW_NORMAL;

    ::ShellExecuteEx(&sh);
  }
Esempio n. 10
0
  void cOpenGLControl::Create(cWindow& parent, int idControl)
  {
    // Register our window class
    RegisterClass();

    // Create the OpenGL control
    control = ::CreateWindowEx(0, TEXT(LIBWIN32MM_OPENGL_CONTROLCLASS), TEXT(""), WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_VISIBLE | WS_TABSTOP, 0, 0, 0, 0, parent.GetWindowHandle(), (HMENU)idControl, GetHInstance(), (LPVOID)0);

    parent.SetControlDefaultFont(control);

    UpdateSize();

    // Set our user data for this window
    ::SetProp(control, TEXT("cOpenGLControlThis"), (HANDLE)this);
  }
Esempio n. 11
0
    void cWindowManager::_RenderWindow(const cWindow& widget) const
    {
      const float title_bar_height = widget.GetTitleBarHeight();

      // Draw the top bar
      SetColourFromThemeColourAndAlpha(theme.GetColourWindowTitleBar());
      _RenderRectangle(widget.GetX(), widget.GetY(), widget.GetWidth(), title_bar_height);

      // Draw the rest of the window
      SetColourFromThemeColourAndAlpha(theme.GetColourWindowBackground());
      _RenderRectangle(widget.GetX(), widget.GetY() + title_bar_height, widget.GetWidth(), widget.GetHeight() - title_bar_height);

#if 0
      // Draw the caption if this window has one
      if (widget.HasCaption()) {
        /*glPushAttrib(GL_LIST_BIT | GL_CURRENT_BIT  | GL_ENABLE_BIT);
          {
            render::ApplyMaterial apply(pMaterial);

            pContext->SelectTextureUnit0();

            glMatrixMode(GL_TEXTURE);
            glPushMatrix();
              glLoadIdentity();

              glMatrixMode(GL_MODELVIEW);

              glColor4f(0.0f, 0.0f, 0.0f, 1.0f);*/

              //pFontWindowCaption->printfCenteredHorizontallyVertically(widget.GetX(), widget.GetY(),
              //  widget.GetWidth(), bar_height,
              //  breathe::string::ToUTF8(widget.GetCaption()).c_str());
              pFontWindowCaption->PrintCenteredHorizontally(widget.GetX(), widget.GetY(),
                widget.GetWidth(), widget.GetCaption());

              //glMatrixMode(GL_TEXTURE);
            //glPopMatrix();
          //}
        //glPopAttrib();
      }
#endif
    }
Esempio n. 12
0
  int cTaskDialog::Run(cWindow& parent, const cTaskDialogSettings& settings)
  {
    // Create our task dialog
    TASKDIALOGCONFIG tdc = { 0 };
    tdc.cbSize = sizeof(tdc);
    tdc.dwFlags = TDF_ALLOW_DIALOG_CANCELLATION;
    if (settings.bIsCheckBoxTickedInitially) tdc.dwFlags |= TDF_VERIFICATION_FLAG_CHECKED;
    tdc.dwCommonButtons = (settings.bCloseButtonText ? TDCBF_CLOSE_BUTTON : TDCBF_CANCEL_BUTTON);
    tdc.hwndParent = parent.GetWindowHandle();
    tdc.hInstance = GetHInstance();

    //tdc.hMainIcon = hIcon;

    switch (settings.type) {
      case cTaskDialogSettings::TYPE::INFORMATION: {
        tdc.pszMainIcon = TD_INFORMATION_ICON;
        break;
      }
      case cTaskDialogSettings::TYPE::WARNING: {
        tdc.pszMainIcon = TD_ERROR_ICON;
        break;
      }
      case cTaskDialogSettings::TYPE::ERROR: {
        tdc.pszMainIcon = TD_ERROR_ICON;
        break;
      }
    };

    tdc.pszWindowTitle = settings.sCaption.c_str();
    tdc.pszMainInstruction = settings.sInstructions.c_str();
    tdc.pszContent = settings.sContent.c_str();

    // Add our buttons
    TASKDIALOG_BUTTON* pButtons = nullptr;
    const size_t nButtons = settings.items.size();
    if (!settings.items.empty()) {
      tdc.dwFlags |= TDF_USE_COMMAND_LINKS;

      pButtons = new TASKDIALOG_BUTTON[nButtons];
      for (size_t i = 0; i < nButtons; i++) {
        pButtons[i].nButtonID = settings.items[i].iCommandID;
        string_t sText(settings.items[i].sText);
        if (!settings.items[i].sTextDescription.empty()) {
          sText += TEXT("\n");
          sText += settings.items[i].sTextDescription;
        }

        const size_t nSize = sText.length() + 1;
        pButtons[i].pszButtonText = new wchar_t[nSize];
        wcscpy_s((wchar_t*)(pButtons[i].pszButtonText), nSize, sText.c_str());
      }

      tdc.pButtons = pButtons;
      tdc.cButtons = UINT(nButtons);

      tdc.nDefaultButton = settings.iDefaultItemCommandID;
    }

    /*PCWSTR      pszExpandedInformation;
    PCWSTR      pszExpandedControlText;
    PCWSTR      pszCollapsedControlText;*/

    tdc.pfCallback = _TaskDialogCallbackProc;
    tdc.lpCallbackData = LONG_PTR(this);

    if (settings.bIsProgressBarVisible) {
      tdc.dwFlags |= TDF_CALLBACK_TIMER | TDF_SHOW_PROGRESS_BAR;
    }

    // Checkbox
    if (settings.bIsCheckBoxVisible) {
      tdc.dwFlags |= TDF_EXPAND_FOOTER_AREA;
      tdc.pszVerificationText = settings.sCheckBoxTitle.c_str();
    }

    // Run the task dialog
    int iButton = 0;
    //BOOL bResult = FALSE;
    const HRESULT rResult = TaskDialogIndirect(&tdc, &iButton, NULL, nullptr /*&bResult*/);
    assert(rResult == S_OK);

    // Clear our window handle
    hwndWindow = NULL;

    // Destroy our buttons
    if (pButtons != nullptr) {
      for (size_t i = 0; i < nButtons; i++) delete [] pButtons[i].pszButtonText;
      delete [] pButtons;
    }

    // If there was an error then pretend the user cancelled
    if (rResult != S_OK) iButton = IDCANCEL;
    
    // If no valid selection was made then pretend the user cancelled
    if (iButton < 0) iButton = IDCANCEL;

    // Return the button that was selected
    return iButton;
  }