void CMouseHandler::DrawCursor(void) { if (guihandler) guihandler->DrawCentroidCursor(); if (hide || (cursorText == "none")) return; if (!currentCursor || (hardwareCursor && currentCursor->hwValid)) { return; } // draw the 'software' cursor if (cursorScale >= 0.0f) { currentCursor->Draw(lastx, lasty, cursorScale); } else { CMouseCursor* nc = cursorFileMap["cursornormal"]; if (nc == NULL) { currentCursor->Draw(lastx, lasty, -cursorScale); } else { nc->Draw(lastx, lasty, 1.0f); if (currentCursor != nc) { currentCursor->Draw(lastx + nc->GetMaxSizeX(), lasty + nc->GetMaxSizeY(), -cursorScale); } } } }
void CCursorIcons::Draw() { if (icons.empty() || !cmdColors.UseQueueIcons()) { return; } glDepthMask(GL_FALSE); glEnable(GL_TEXTURE_2D); glMatrixMode(GL_PROJECTION); glPushMatrix(); glLoadIdentity(); gluOrtho2D(0.0f, 1.0f, 0.0f, 1.0f); glMatrixMode(GL_MODELVIEW); glPushMatrix(); glLoadIdentity(); glEnable(GL_TEXTURE_2D); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glAlphaFunc(GL_GREATER, 0.01f); glColor4f(1.0f, 1.0f, 1.0f, cmdColors.QueueIconAlpha()); int currentCmd = (icons.begin()->command + 1); // force the first binding CMouseCursor* currentCursor = NULL; std::set<Icon>::iterator it; for (it = icons.begin(); it != icons.end(); ++it) { if (it->command != currentCmd) { currentCmd = it->command; currentCursor = GetCursor(currentCmd); if (currentCursor != NULL) { currentCursor->BindTexture(); } } if (currentCursor != NULL) { float3 winPos = camera->CalcWindowCoordinates(it->pos); if (winPos.z <= 1.0f) { currentCursor->DrawQuad((int)winPos.x, (int)winPos.y); } } } glMatrixMode(GL_PROJECTION); glPopMatrix(); glMatrixMode(GL_MODELVIEW); glPopMatrix(); glBindTexture(GL_TEXTURE_2D, 0); glDisable(GL_TEXTURE_2D); glDepthMask(GL_TRUE); glViewport(gu->screenxPos,0,gu->screenx,gu->screeny); // clear the list icons.clear(); }
void CMouseHandler::DrawCursor() { assert(currentCursor); if (guihandler) guihandler->DrawCentroidCursor(); if (locked) { if (crossSize > 0.0f) { const float xscale = (crossSize / globalRendering->viewSizeX); const float yscale = (crossSize / globalRendering->viewSizeY); glPushMatrix(); glTranslatef(0.5f - globalRendering->pixelX * 0.5f, 0.5f - globalRendering->pixelY * 0.5f, 0.f); glScalef(xscale, yscale, 1.f); if (gu->fpsMode) { DrawFPSCursor(); } else { DrawScrollCursor(); } glPopMatrix(); } glEnable(GL_TEXTURE_2D); return; } if (hide) return; if (hardwareCursor && currentCursor->hwValid) return; // draw the 'software' cursor if (cursorScale >= 0.0f) { currentCursor->Draw(lastx, lasty, cursorScale); } else { // hovered minimap, show default cursor and draw `special` cursor scaled-down bottom right of the default one CMouseCursor* nc = cursorFileMap["cursornormal"]; if (nc == NULL) { currentCursor->Draw(lastx, lasty, -cursorScale); } else { nc->Draw(lastx, lasty, 1.0f); if (currentCursor != nc) { currentCursor->Draw(lastx + nc->GetMaxSizeX(), lasty + nc->GetMaxSizeY(), -cursorScale); } } } }
void CMouseHandler::DrawCursor(void) { if (hide) return; CMouseCursor *mc; map<string, CMouseCursor *>::iterator i; if ((i = cursors.find(cursorText)) != cursors.end()) { mc = i->second; } else { //info->AddLine("Unknown cursor: %s", cursorText.c_str()); mc = cursors[""]; } mc->Draw(lastx, lasty); }
void CCursorIcons::DrawCursors() { if (icons.empty() || !cmdColors.UseQueueIcons()) { return; } glMatrixMode(GL_PROJECTION); glPushMatrix(); glLoadIdentity(); gluOrtho2D(0.0f, 1.0f, 0.0f, 1.0f); glMatrixMode(GL_MODELVIEW); glPushMatrix(); glLoadIdentity(); glColor4f(1.0f, 1.0f, 1.0f, cmdColors.QueueIconAlpha()); int currentCmd = (icons.begin()->cmd + 1); // force the first binding CMouseCursor* currentCursor = NULL; std::set<Icon>::iterator it; for (it = icons.begin(); it != icons.end(); ++it) { const int command = it->cmd; if (command != currentCmd) { currentCmd = command; currentCursor = GetCursor(currentCmd); if (currentCursor != NULL) { currentCursor->BindTexture(); } } if (currentCursor != NULL) { const float3 winPos = camera->CalcWindowCoordinates(it->pos); if (winPos.z <= 1.0f) { currentCursor->DrawQuad((int)winPos.x, (int)winPos.y); } } } DrawTexts(); // use the same transformation glMatrixMode(GL_PROJECTION); glPopMatrix(); glMatrixMode(GL_MODELVIEW); glPopMatrix(); }
bool CMouseHandler::AssignMouseCursor( const std::string& cmdName, const std::string& fileName, CMouseCursor::HotSpot hotSpot, bool overwrite ) { const auto cmdIt = cursorCommandMap.find(cmdName); const auto fileIt = cursorFileMap.find(fileName); const bool haveCmd = (cmdIt != cursorCommandMap.end()); const bool haveFile = (fileIt != cursorFileMap.end()); if (haveCmd && !overwrite) return false; // already assigned if (haveFile) { // cursor is already loaded, reuse it cursorCommandMap[cmdName] = fileIt->second; return true; } CMouseCursor newCursor = std::move(CMouseCursor::New(fileName, hotSpot)); if (!newCursor.IsValid()) return false; const int commandCursorIdx = haveCmd? cmdIt->second: -1; // assign the new cursor and remap indices loadedCursors.emplace_back(); loadedCursors.back() = std::move(newCursor); cursorFileMap[fileName] = loadedCursors.size() - 1; cursorCommandMap[cmdName] = loadedCursors.size() - 1; // switch to the null-cursor if our active one is being (re)assigned if (activeCursorIdx == commandCursorIdx) SetCursor("none", true); return true; }
bool CMouseHandler::ReplaceMouseCursor( const string& oldName, const string& newName, CMouseCursor::HotSpot hotSpot ) { const auto fileIt = cursorFileMap.find(oldName); if (fileIt == cursorFileMap.end()) return false; CMouseCursor newCursor = std::move(CMouseCursor::New(newName, hotSpot)); if (!newCursor.IsValid()) return false; // leave the old one loadedCursors[fileIt->second] = std::move(newCursor); // update current cursor if necessary if (activeCursorIdx == fileIt->second) SetCursor(cursorText, true); return true; }
void CMouseHandler::DrawCursor(void) { if (guihandler) { guihandler->DrawCentroidCursor(); } if (hide || (cursorText == "none")) { return; } CMouseCursor* mc; map<string, CMouseCursor*>::iterator it = cursorCommandMap.find(cursorText); if (it != cursorCommandMap.end()) { mc = it->second; } else { mc = cursorFileMap["cursornormal"]; } if (mc == NULL) { return; } if (cursorScale >= 0.0f) { mc->Draw(lastx, lasty, cursorScale); } else { CMouseCursor* nc = cursorFileMap["cursornormal"]; if (nc == NULL) { mc->Draw(lastx, lasty, -cursorScale); } else { nc->Draw(lastx, lasty, 1.0f); if (mc != nc) { mc->Draw(lastx + nc->GetMaxSizeX(), lasty + nc->GetMaxSizeY(), -cursorScale); } } } }