MouseInput::MouseInput( HWND ghWnd, Camera* p_camera, int wndWidth, int wndHeight ) { RAWINPUTDEVICE Rid[1]; Rid[0].usUsagePage = HID_USAGE_PAGE_GENERIC; Rid[0].usUsage = HID_USAGE_GENERIC_MOUSE; Rid[0].dwFlags = RIDEV_INPUTSINK; Rid[0].hwndTarget = ghWnd; mhWnd = ghWnd; RegisterRawInputDevices(Rid, 1, sizeof(Rid[0])); ShowCursor(true); fps = false; dx = 0; dy = 0; winHeight = wndHeight; winWidth = wndWidth; mXScale = ( (2 * PI) / (winWidth) ); mYScale = ( (PI / 3) / winHeight ); m_camera = p_camera; POINT pt; pt.x = winWidth / 2; pt.y = winHeight / 2; ClientToScreen(ghWnd, &pt); setCenterPos(pt); }
void CProgressWindow::Init(bool global_only) { global_progress = local_progress = 100; showFooter(false); shadow = true; int x_item = 10; int y_item = 10; setWidthP(75); int w_item = width-2*x_item; int h_item = 14; int h_pbar = 20; w_bar_frame = 0; //create status text object status_txt = new CComponentsLabel(); int h_txt = max(g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight(), h_item); status_txt->setDimensionsAll(x_item, y_item, w_item, h_txt); status_txt->setColorBody(col_body); status_txt->doPaintTextBoxBg(true); addWindowItem(status_txt); y_item += h_txt + 10; //create local_bar object local_bar = new CProgressBar(); if (!global_only) { local_bar->allowPaint(false); local_bar->setDimensionsAll(x_item, y_item, w_item, h_pbar); local_bar->setColorBody(col_body); local_bar->setActiveColor(COL_MENUCONTENT_PLUS_7); local_bar->setFrameThickness(w_bar_frame); local_bar->setColorFrame(COL_MENUCONTENT_PLUS_7); addWindowItem(local_bar); y_item += 2*h_pbar; } //create global_bar object global_bar = new CProgressBar(); global_bar->allowPaint(false); global_bar->setDimensionsAll(x_item, y_item, w_item, h_pbar); global_bar->setColorBody(col_body); global_bar->setActiveColor(COL_MENUCONTENT_PLUS_7); global_bar->setFrameThickness(w_bar_frame); global_bar->setColorFrame(COL_MENUCONTENT_PLUS_7); addWindowItem(global_bar); y_item += 2*h_pbar; h_height = ccw_head->getHeight(); height = y_item + h_height; setCenterPos(); }
//Public constructor LinkNodeItem::LinkNodeItem(int in_x, int in_y, const QColor& normal, const QColor& active, QGraphicsItem* parent): QGraphicsEllipseItem(0, 0, radius * 2, radius * 2, parent) { normal_color = normal; active_color = active; if (normal_color == Qt::transparent) normal_pen = Qt::NoPen; setBrush(normal_color); setPen(normal_pen); setCenterPos(QPoint(in_x, in_y)); setZValue(1); ChartScene* chart_scene; if (scene() && (chart_scene = dynamic_cast<ChartScene*>(scene()))) { grid_size = chart_scene->gridSize(); } else grid_size = 0; }
void Spawn::load(TiXmlElement* node) { Position centerPos; centerPos.x = node->readType<int>("centerx"); centerPos.y = node->readType<int>("centery"); centerPos.z = node->readType<int>("centerz"); setCenterPos(centerPos); setRadius(node->readType<int32>("radius")); CreatureTypePtr cType(nullptr); for(TiXmlElement* cNode = node->FirstChildElement(); cNode; cNode = cNode->NextSiblingElement()) { if(cNode->ValueStr() != "monster" && cNode->ValueStr() != "npc") stdext::throw_exception(stdext::format("invalid spawn-subnode %s", cNode->ValueStr())); std::string cName = cNode->Attribute("name"); stdext::tolower(cName); stdext::trim(cName); stdext::ucwords(cName); if (!(cType = g_creatures.getCreatureByName(cName))) continue; cType->setSpawnTime(cNode->readType<int>("spawntime")); Otc::Direction dir = Otc::North; int16 dir_ = cNode->readType<int16>("direction"); if(dir_ >= Otc::East && dir_ <= Otc::West) dir = (Otc::Direction)dir_; cType->setDirection(dir); Position placePos; placePos.x = centerPos.x + cNode->readType<int>("x"); placePos.y = centerPos.y + cNode->readType<int>("y"); placePos.z = cNode->readType<int>("z"); cType->setRace(cNode->ValueStr() == "npc" ? CreatureRaceNpc : CreatureRaceMonster); addCreature(placePos, cType); } }
void Drawable::moveCenterPos(int dx, int dy) { setCenterPos(m_center.x() + dx, m_center.y() + dy); }