Thought::Thought(int id, QSettings &s, QObject *parent) : QObject(parent) , m_title(s.value("title", "Unknown").toString()) , m_description(s.value("thought", m_title).toString()) , m_effect(s.value("value", 0).toInt()) , m_subtype(s.value("subthoughts_type",-1).toInt()) , m_id(id) { if(m_effect == 0){ m_color = c_neu(); } else if(m_effect > 0){ m_color = c_pos(); }else{ m_color = c_neg(); } //-1000 to +1000 //(x - from_min) * (to_max - to_min) / (from_max - from_min) + to_min int alpha = (((m_effect + 50) * (255-75)) / 100) + 75; if(alpha > 255) alpha = 255; else if(alpha < 0) alpha = 0; if(m_effect < 0) alpha = 255 - alpha; m_color.setAlpha(alpha); }
void SpecialZone::onTick(const int slot_id) { PlayerSlot &slot = PlayerManager->get_slot(slot_id); Object *o = slot.getObject(); if (o == NULL) return; v2<float> pos, vel; o->get_position(pos); o->get_velocity(vel); v2<int> left_pos, right_pos; o->get_position(left_pos); o->get_position(right_pos); right_pos += o->size.convert<int>(); v2<int> c_pos(position.x, position.y); c_pos += size / 2; int o_z = getBox(o->get_z()); //LOG_DEBUG(("zone zbox: %d, object zbox: %d", position.z, o_z)); if (name == "right") { if (right_pos.x >= c_pos.x && o_z != (position.z + 1) && vel.x > 0) o->set_zbox((position.z + 1) * 2000); if (right_pos.x < c_pos.x && o_z != position.z && vel.x < 0) o->set_zbox(position.z * 2000); } else if (name == "left") { if (left_pos.x < c_pos.x && o_z != (position.z + 1) && vel.x < 0) o->set_zbox((position.z + 1) * 2000); if (left_pos.x >= c_pos.x && o_z != position.z && vel.x > 0) o->set_zbox(position.z * 2000); } //LOG_DEBUG(("delta left: %d, %d, delta right: %d, %d", left_pos.x - c_pos.x, left_pos.y - c_pos.y, right_pos.x - c_pos.x, right_pos.y - c_pos.y)); }
void StartupId::update_startupid() { int yoffset = 0; if( blinking ) { XSetWindowBackgroundPixmap( QX11Info::display(), startup_window, pixmaps[ color_to_pixmap[ color_index ]].handle()); XClearWindow( QX11Info::display(), startup_window ); if( ++color_index >= ( sizeof( color_to_pixmap ) / sizeof( color_to_pixmap[ 0 ] ))) color_index = 0; } else if( bouncing ) { yoffset = frame_to_yoffset[ frame ]; QPixmap pixmap = pixmaps[ frame_to_pixmap[ frame ] ]; XSetWindowBackgroundPixmap( QX11Info::display(), startup_window, pixmap.handle()); XClearWindow( QX11Info::display(), startup_window ); if ( !pixmap.mask().isNull() ) // set mask XShapeCombineMask( QX11Info::display(), startup_window, ShapeBounding, 0, 0, pixmap.mask().handle(), ShapeSet ); else // clear mask XShapeCombineMask( QX11Info::display(), startup_window, ShapeBounding, 0, 0, None, ShapeSet ); if ( ++frame >= ( sizeof( frame_to_yoffset ) / sizeof( frame_to_yoffset[ 0 ] ) ) ) frame = 0; } Window dummy1, dummy2; int x, y; int dummy3, dummy4; unsigned int dummy5; if( !XQueryPointer( QX11Info::display(), QX11Info::appRootWindow(), &dummy1, &dummy2, &x, &y, &dummy3, &dummy4, &dummy5 )) { XUnmapWindow( QX11Info::display(), startup_window ); update_timer.start( 100 ); return; } QPoint c_pos( x, y ); int cursor_size = 0; #ifdef HAVE_XCURSOR cursor_size = XcursorGetDefaultSize( QX11Info::display()); #endif int X_DIFF; if( cursor_size <= 16 ) X_DIFF = 8 + 7; else if( cursor_size <= 32 ) X_DIFF = 16 + 7; else if( cursor_size <= 48 ) X_DIFF = 24 + 7; else X_DIFF = 32 + 7; int Y_DIFF = X_DIFF; XMoveWindow( QX11Info::display(), startup_window, c_pos.x() + X_DIFF, c_pos.y() + Y_DIFF + yoffset ); XMapWindow( QX11Info::display(), startup_window ); XRaiseWindow( QX11Info::display(), startup_window ); update_timer.start( bouncing ? 30 : 100 ); QApplication::flush(); }
void StartupId::update_startupid() { int yoffset = 0; if( blinking ) { startup_widget->setBackgroundPixmap( pixmaps[ color_to_pixmap[ color_index ]] ); if( ++color_index >= ( sizeof( color_to_pixmap ) / sizeof( color_to_pixmap[ 0 ] ))) color_index = 0; } else if( bouncing ) { yoffset = frame_to_yoffset[ frame ]; QPixmap pm = pixmaps[ frame_to_pixmap[ frame ] ]; startup_widget->setBackgroundPixmap( pm ); if ( pm.mask() != NULL ) startup_widget->setMask( *pm.mask() ); else startup_widget->clearMask(); if ( ++frame >= ( sizeof( frame_to_yoffset ) / sizeof( frame_to_yoffset[ 0 ] ) ) ) frame = 0; } Window dummy1, dummy2; int x, y; int dummy3, dummy4; unsigned int dummy5; if( !XQueryPointer( qt_xdisplay(), qt_xrootwin(), &dummy1, &dummy2, &x, &y, &dummy3, &dummy4, &dummy5 )) { startup_widget->hide(); update_timer.start( 100, true ); return; } QPoint c_pos( x, y ); int cursor_size = 0; #ifdef HAVE_XCURSOR cursor_size = XcursorGetDefaultSize( qt_xdisplay()); #endif int X_DIFF; if( cursor_size <= 16 ) X_DIFF = 8 + 7; else if( cursor_size <= 32 ) X_DIFF = 16 + 7; else if( cursor_size <= 48 ) X_DIFF = 24 + 7; else X_DIFF = 32 + 7; int Y_DIFF = X_DIFF; if( startup_widget->x() != c_pos.x() + X_DIFF || startup_widget->y() != c_pos.y() + Y_DIFF + yoffset ) startup_widget->move( c_pos.x() + X_DIFF, c_pos.y() + Y_DIFF + yoffset ); startup_widget->show(); XRaiseWindow( qt_xdisplay(), startup_widget->winId()); update_timer.start( bouncing ? 30 : 100, true ); QApplication::flushX(); }
void HWLight::SetView(const std::vector<Vector3D> &frustum) { if (Directionnal) { Vector3D Side(0.0f, 1.0f, 0.0f); Vector3D Up(Side * Dir); Up.unit(); Side = Dir * Up; Side.unit(); float mx = 0.0f, Mx = 0.0f; float my = 0.0f, My = 0.0f; float mz = 0.0f, Mz = 0.0f; for (unsigned int i = 0; i < frustum.size(); i++) { float X = frustum[i] % Side; float Z = frustum[i] % Dir; float Y = frustum[i] % Up; if (i == 0) { mx = Mx = X; my = My = Y; mz = Mz = Z; } else { mx = Math::Min(mx, X); Mx = Math::Max(Mx, X); my = Math::Min(my, Y); My = Math::Max(My, Y); mz = Math::Min(mz, Z); Mz = Math::Max(Mz, Z); } } Vector3D c_pos(Mz * Dir + 0.5f * (mx + Mx) * Side + 0.5f * (my + My) * Up); const float zfar = Mz - mz; const float znear = -128.0f; const float widthFactor = (Mx - mx) / (My - my); const float f = 0.5f * (My - my); glMatrixMode (GL_PROJECTION); glLoadIdentity (); glOrtho(-widthFactor * f, widthFactor * f, -f, f, znear, zfar); Vector3D c_at(c_pos - Dir); gluLookAt(c_pos.x, c_pos.y, c_pos.z, c_at.x, c_at.y, c_at.z, Up.x, Up.y, Up.z); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); } else { float zfar = 1000.0f; float znear = 0.01f; float widthFactor = 1.0f; //float f = 10.0f; glMatrixMode (GL_PROJECTION); glLoadIdentity (); glFrustum(-widthFactor * znear, widthFactor * znear, -0.75f * znear, 0.75f * znear, znear, zfar); Vector3D Up(Pos * Dir); Up.unit(); gluLookAt(Pos.x, Pos.y, Pos.z, Dir.x, Dir.y, Dir.z, Up.x, Up.y, Up.z); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); } }