Example #1
0
//-----------------------------------------------------------------------------
// Purpose: Input handler that does the screen fade.
//-----------------------------------------------------------------------------
void CEnvFade::InputFade( inputdata_t &inputdata )
{
	int fadeFlags = 0;

	if ( m_spawnflags & SF_FADE_IN )
	{
		fadeFlags |= FFADE_IN;
	}
	else
	{
		fadeFlags |= FFADE_OUT;
	}

	if ( m_spawnflags & SF_FADE_MODULATE )
	{
		fadeFlags |= FFADE_MODULATE;
	}

	if ( m_spawnflags & SF_FADE_STAYOUT )
	{
		fadeFlags |= FFADE_STAYOUT;
	}

	if ( m_spawnflags & SF_FADE_ONLYONE )
	{
		if ( inputdata.pActivator->IsNetClient() )
		{
			UTIL_ScreenFade( inputdata.pActivator, m_clrRender, Duration(), HoldTime(), fadeFlags );
		}
	}
	else
	{
		UTIL_ScreenFadeAll( m_clrRender, Duration(), HoldTime(), fadeFlags|FFADE_PURGE );
	}

	m_OnBeginFade.FireOutput( inputdata.pActivator, this );
}
bool ObjectManipulation::placeObject(string arm_name, double x_offset, double y_offset, double z_offset, double max_seconds_wait_for_conclusion) {
	if (processing_srv_.response.graspable_objects.empty() || processing_srv_.response.collision_object_names.empty()) {
		return false;
	}

	geometry_msgs::PoseStamped place_location;
	place_location.header.frame_id = processing_srv_.response.graspable_objects.at(0).reference_frame_id;
	place_location.pose.orientation.w = 1;
	place_location.header.stamp = ros::Time::now();
	place_location.pose.position.x += x_offset;
	place_location.pose.position.y += y_offset;

	direction_.header.stamp = ros::Time::now();
	direction_.header.frame_id = "base_link";
	direction_.vector.x = 0;
	direction_.vector.y = 0;
	direction_.vector.z = -1;

	ROS_INFO("Calling the place action");
	object_manipulation_msgs::PlaceGoal place_goal;
	place_goal.place_locations.push_back(place_location);
	place_goal.collision_object_name = processing_srv_.response.collision_object_names.at(0);
	place_goal.collision_support_surface_name = processing_srv_.response.collision_support_surface_name;
	place_goal.grasp = pickup_result_.grasp;
	place_goal.arm_name = arm_name;
	place_goal.place_padding = 0.02;
	place_goal.desired_retreat_distance = 0.1;
	place_goal.min_retreat_distance = 0.05;
	place_goal.approach.direction = direction_;
	place_goal.approach.desired_distance = z_offset;
	place_goal.approach.min_distance = 0.05;
	place_goal.use_reactive_place = false;


	place_client_.sendGoal(place_goal);
	ROS_INFO("Waiting for the place action...");
	if (!place_client_.waitForResult(Duration(max_seconds_wait_for_conclusion))) {
		return false;
	}

	object_manipulation_msgs::PlaceResult place_result = *(place_client_.getResult());
	if (place_client_.getState() != actionlib::SimpleClientGoalState::SUCCEEDED) {
		ROS_ERROR("Place failed with error code %d", place_result.manipulation_result.value);
		return false;
	}

	ROS_INFO("Object moved");
	return true;
}
Example #3
0
////////////////////////////////////////////////////////////////////////////////
// Set the minimum and maximum widths for the value.
void ColumnRecur::measure (Task& task, unsigned int& minimum, unsigned int& maximum)
{
  if (_style == "default" ||
      _style == "duration")
  {
    minimum = maximum = Duration (task.get ("recur")).formatCompact ().length ();
  }
  else if (_style == "indicator")
  {
    if (task.has (_name))
      minimum = maximum = context.config.get ("recurrence.indicator").length ();
  }
  else
    throw format (STRING_COLUMN_BAD_FORMAT, _name, _style);
}
Example #4
0
////////////////////////////////////////////////////////////////////////////////
// Set the minimum and maximum widths for the value.
void ColumnDue::measure (Task& task, int& minimum, int& maximum)
{
  minimum = maximum = 0;

  if (task.has (_name))
  {
    if (_style == "countdown")
    {
      Date date ((time_t) strtol (task.get (_name).c_str (), NULL, 10));
      Date now;
      minimum = maximum = Duration (now - date).format ().length ();
    }
    else
      ColumnDate::measure (task, minimum, maximum);
  }
}
Example #5
0
void TExportZone::TrackOutMarker(BPoint mousePt)
{					
	//	Constrain to out time of cue sheet
	uint32 outPixels = TimeToPixels( Duration() - StartTime(), GetCurrentTimeFormat(), GetCurrentResolution());
	
	if (mousePt.x > outPixels)
		mousePt.x = outPixels;

	//	Don't allow overlap with m_InRect
	if ( (mousePt.x-kExportSliderWidth) < m_InRect.right)
		mousePt.x = m_InRect.right + kExportSliderWidth;

	// Save oldRect for redraw														
	BRect oldRect 	= m_OutRect;	
	m_OutRect.right = mousePt.x;	
	m_OutRect.left = m_OutRect.right - kExportSliderWidth;	
	
	
	// Exit if there is no change in position
	if (oldRect == m_OutRect)
		return;

	//	Update m_ExportChannel
	m_ExportChannel.right = m_OutRect.left;
	
	//	Clean up old position
	BRect updateRect = oldRect;
	
	if (m_OutRect.left <= oldRect.left)
	{
		updateRect.left = m_OutRect.left;		
	}
	else
	{
		updateRect.right  = m_OutRect.right;
	}
	
	Draw(updateRect);
	
	//	Update CueSheet variable
	uint32 newOutTime = StartTime() + PixelsToTime(m_OutRect.right, GetCurrentTimeFormat(), GetCurrentResolution());
	m_CueSheetWindow->GetCueSheetView()->SetExportStopTime(newOutTime);

	//	Update text
	m_CueSheetWindow->GetExportTimeView()->DrawOutText();
	
}
Example #6
0
MoveSpline::UpdateResult MoveSpline::_updateState(int32& ms_time_diff)
{
	if (ms_time_diff < 0)
	{
		ms_time_diff = 0;
		return Result_Arrived;
	}

    if (Finalized())
    {
        ms_time_diff = 0;
        return Result_Arrived;
    }

    UpdateResult result = Result_None;

    int32 minimal_diff = std::min(ms_time_diff, segment_time_elapsed());
    ASSERT(minimal_diff >= 0);
    time_passed += minimal_diff;
    ms_time_diff -= minimal_diff;

    if (time_passed >= next_timestamp())
    {
        ++point_Idx;
        if (point_Idx < spline.last())
        {
            result = Result_NextSegment;
        }
        else
        {
            if (spline.isCyclic())
            {
                point_Idx = spline.first();
                time_passed = time_passed % Duration();
                result = Result_NextSegment;
            }
            else
            {
                _Finalize();
                ms_time_diff = 0;
                result = Result_Arrived;
            }
        }
    }

    return result;
}
Example #7
0
Duration
Time::operator-(const rclcpp::Time & rhs) const
{
  if (rcl_time_.clock_type != rhs.rcl_time_.clock_type) {
    throw std::runtime_error("can't subtract times with different time sources");
  }

  if (rclcpp::sub_will_overflow(rcl_time_.nanoseconds, rhs.rcl_time_.nanoseconds)) {
    throw std::overflow_error("time subtraction leads to int64_t overflow");
  }

  if (rclcpp::sub_will_underflow(rcl_time_.nanoseconds, rhs.rcl_time_.nanoseconds)) {
    throw std::underflow_error("time subtraction leads to int64_t underflow");
  }

  return Duration(rcl_time_.nanoseconds - rhs.rcl_time_.nanoseconds);
}
Example #8
0
//--------------------------------------------------------------------------------------
// Name: GetPacketCumulativeBytesSize()
// Desc: Gets the packet count and the total byte size of the 'dpds' chunk.
//--------------------------------------------------------------------------------------
HRESULT WaveFile::GetPacketCumulativeBytesSize(DWORD* pdwPacketCount, DWORD* pdwBufferSize)
{
    assert( m_DpdsChunk.IsValid() );

    if (!m_DpdsChunk.IsValid())
        return E_HANDLE;

    WAVEFORMATEXTENSIBLE wfxFormat;
    GetFormat( &wfxFormat );
    
    // Packet count: length of the 'data' chunk divided by number of bytes per packet
    *pdwPacketCount = Duration() / wfxFormat.Format.nBlockAlign;

    *pdwBufferSize = m_DpdsChunk.GetDataSize();

    return S_OK;
}
Example #9
0
 void
 checkSimpleQuantisation ()
   {
     FixedFrameQuantiser fixQ(25);
     
     uint frames = (rand() % MAX_FRAMES);
     FSecs dirt  = (F25 / (2 + rand() % DIRT_GRAIN));
     
     Time rawTime = Time(frames*F25) + Duration(dirt);            ////////////////TICKET #939 : should better use 64bit base type for FSecs ??
     
     CHECK (Time( frames   *F25) <= rawTime);
     CHECK (Time((frames+1)*F25) >  rawTime);
     
     Time quantTime (fixQ.gridAlign (rawTime));
     
     CHECK (Time(frames*F25) == quantTime);
   }
Example #10
0
File: game.c Project: zhu-jz/turtle
void DoGameMove(GAME *Game, int Move, double Value, double Time) {

   if (! IsLegalMove(Game->Board,Move)) FatalError("Illegal move in DoGameMove()");

   TurnTime = (Trust && Time >= 0.0) ? Time : Duration(TurnBegin,CurrentTime());
   ElapsedTime[Game->Board->Colour>0] += TurnTime;

   DoMove(Game->Board,Move);

   Game->Move[Game->MoveNo].Move  = Move;
   Game->Move[Game->MoveNo].Value = Value;
   Game->Move[Game->MoveNo].Time  = TurnTime;
   Game->MoveNo++;
   Game->Move[Game->MoveNo].Move  = NO_MOVE;

   TurnBegin = CurrentTime();
}
Example #11
0
//-----------------------------------------------------------------------
void DebugNavigator::Draw(DrawingContext & drawingContext)
{
    constexpr float minFramerate = 10.0f;
    constexpr float maxFramerate = 60.0f;
    constexpr std::uint16_t maxHistories = 20;

    {
        if (clock->TotalGameTime() - duration > Duration(0.2))
        {
            auto frameRate = clock->FrameRate();
            frameRateString = StringFormat("%4.2f fps", frameRate);
            frameRates.push_back(MathHelper::Clamp(frameRate, minFramerate, maxFramerate));

            if (frameRates.size() > maxHistories)
            {
                frameRates.pop_front();
            }
            duration = clock->TotalGameTime();
        }
    }

    auto transform = Transform() * drawingContext.Top();
    {
        auto graphTransform = Matrix3x2::CreateTranslation(Vector2{0, 16}) * transform;

        constexpr std::uint16_t maxGraphHeight = 26;
        constexpr float graphMarginLeft = 1.0f;

        auto graghWidth = (static_cast<float>(Width()) / maxHistories);

        std::int32_t startPosition = graghWidth * (maxHistories - frameRates.size());
        std::int32_t graphX = startPosition;
        for (auto & frameRate: frameRates)
        {
            auto amount = ((frameRate - minFramerate) / (maxFramerate - minFramerate));
            auto graphHeight = MathHelper::Clamp<std::uint16_t>(maxGraphHeight * amount, 1, maxGraphHeight);

            drawingContext.DrawRectangle(graphTransform, Color::CornflowerBlue,
                Rectangle(graphX, maxGraphHeight - graphHeight, graghWidth - graphMarginLeft, graphHeight));
            graphX += graghWidth;
        }
    }

    drawingContext.DrawString(transform * Matrix3x2::CreateTranslation({0.5f, -2.5f}),
        Color::White, FontWeight::Bold, FontSize::Medium, frameRateString);
}
 void
 IBeamTool::set_leading_x (const int x)
 {
   shared_ptr<TimelineState> state = get_state();
   
   // The line below needs handled differently now;  ////////////TODO GTK-3
   //
   //const bool set_playback_period = dragType == Selection;
   
   TimeVar newStartPoint (state->getViewWindow().x_to_time(x));
   Offset selectionLength (pinnedDragTime, newStartPoint);
   
   if (newStartPoint > pinnedDragTime)
     newStartPoint=pinnedDragTime; // use the smaller one as selection start
   
   selectionControl (TimeSpan (newStartPoint, Duration(selectionLength)));
 }
Example #13
0
int64_t
MP3Demuxer::Duration() const {
  if (!mNumParsedFrames) {
    return -1;
  }

  // Assume we know the exact number of frames from the VBR header.
  int64_t numFrames = mParser.VBRInfo().NumFrames();
  if (numFrames < 0) {
    if (mStreamLength < 0) {
      // Unknown length, we can't estimate duration.
      return -1;
    }
    numFrames = (mStreamLength - mFirstFrameOffset) / AverageFrameLength();
  }
  return Duration(numFrames);
}
Example #14
0
  static Try<Duration> parse(const std::string& s)
  {
    // TODO(benh): Support negative durations (i.e., starts with '-').
    size_t index = 0;
    while (index < s.size()) {
      if (isdigit(s[index]) || s[index] == '.') {
        index++;
        continue;
      }

      Try<double> value = numify<double>(s.substr(0, index));

      if (value.isError()) {
        return Error(value.error());
      }

      const std::string unit = s.substr(index);

      if (unit == "ns") {
        return Duration(value.get(), NANOSECONDS);
      } else if (unit == "us") {
        return Duration(value.get(), MICROSECONDS);
      } else if (unit == "ms") {
        return Duration(value.get(), MILLISECONDS);
      } else if (unit == "secs") {
        return Duration(value.get(), SECONDS);
      } else if (unit == "mins") {
        return Duration(value.get(), MINUTES);
      } else if (unit == "hrs") {
        return Duration(value.get(), HOURS);
      } else if (unit == "days") {
        return Duration(value.get(), DAYS);
      } else if (unit == "weeks") {
        return Duration(value.get(), WEEKS);
      } else {
        return Error(
            "Unknown duration unit '" + unit + "'; supported units are"
            " 'ns', 'us', 'ms', 'secs', 'mins', 'hrs', 'days', and 'weeks'");
      }
    }
    return Error("Invalid duration '" + s + "'");
  }
Example #15
0
Duration Duration::fromString(const QString &s, Format format, bool *ok) {
    if (ok) *ok = false;
    QRegExp matcher;
    Duration tmp;
    switch (format) {
        case Format_Hour: {
            matcher.setPattern("^(\\d*)h(\\d*)m$" );
            int pos = matcher.indexIn(s);
            if (pos > -1) {
                tmp.addHours(matcher.cap(1).toUInt());
                tmp.addMinutes(matcher.cap(2).toUInt());
                if (ok) *ok = true;
            }
            break;
        }
        case Format_DayTime: {
            matcher.setPattern("^(\\d*) (\\d*):(\\d*):(\\d*)\\.(\\d*)$" );
            int pos = matcher.indexIn(s);
            if (pos > -1) {
                tmp.addDays(matcher.cap(1).toUInt());
                tmp.addHours(matcher.cap(2).toUInt());
                tmp.addMinutes(matcher.cap(3).toUInt());
                tmp.addSeconds(matcher.cap(4).toUInt());
                tmp.addMilliseconds(matcher.cap(5).toUInt());
                if (ok) *ok = true;
            }
            break;
        }
        case Format_HourFraction: {
            // should be in double format
            bool res;
            double f = QLocale().toDouble(s, &res);
            if (ok) *ok = res;
            if (res) {
                return Duration((qint64)(f)*3600*1000);
            }
            break;
        }
        default:
            qFatal("Unknown format");
            break;
    }
    return tmp;
}
Example #16
0
////////////////////////////////////////////////////////////////////////////////
// Set the minimum and maximum widths for the value.
//
void ColumnUDA::measure (Task& task, int& minimum, int& maximum)
{
  minimum = maximum = 0;

  if (_style == "default")
  {
    std::string value = task.get (_name);
    if (value != "")
    {
      if (_type == "date")
      {
        // Determine the output date format, which uses a hierarchy of definitions.
        //   rc.report.<report>.dateformat
        //   rc.dateformat.report
        //   rc.dateformat.
        Date date ((time_t) strtol (value.c_str (), NULL, 10));
        std::string format = context.config.get ("report." + _report + ".dateformat");
        if (format == "")
          format = context.config.get ("dateformat.report");
        if (format == "")
          format = context.config.get ("dateformat");

        minimum = maximum = date.toString (format).length ();
      }
      else if (_type == "duration")
      {
        minimum = maximum = Duration (value).formatCompact ().length ();
      }
      else if (_type == "string")
      {
        std::string stripped = Color::strip (value);
        maximum = longestLine (stripped);
        minimum = longestWord (stripped);
      }
      else if (_type == "numeric")
      {
        minimum = maximum = value.length ();
      }
    }
  }
  else
    throw format (STRING_COLUMN_BAD_FORMAT, _name, _style);
}
bool ObjectManipulation::pickupObject(string arm_name, float lift_z_distance, double max_seconds_wait_for_conclusion) {
	if (processing_srv_.response.graspable_objects.empty() || processing_srv_.response.collision_object_names.empty()) {
		return false;
	}

	direction_.header.stamp = ros::Time::now();
	direction_.header.frame_id = "base_link";
	direction_.vector.x = 0;
	direction_.vector.y = 0;
	direction_.vector.z = 1;

	object_manipulation_msgs::PickupGoal pickup_goal;
	pickup_goal.target = processing_srv_.response.graspable_objects.at(0);
	pickup_goal.collision_object_name = processing_srv_.response.collision_object_names.at(0);
	pickup_goal.collision_support_surface_name = processing_srv_.response.collision_support_surface_name;
	pickup_goal.arm_name = arm_name;
	pickup_goal.use_reactive_lift = false;
	pickup_goal.use_reactive_execution = false;
	pickup_goal.lift.direction = direction_;
	pickup_goal.lift.desired_distance = lift_z_distance; //cm
	pickup_goal.lift.min_distance = 0.025;
	pickup_goal.ignore_collisions = 1;

	ROS_INFO("Calling the pickup action");
	pickup_client_.sendGoal(pickup_goal);

	ROS_INFO("Waiting for the pickup action...");
	if (!pickup_client_.waitForResult(Duration(max_seconds_wait_for_conclusion))) {
		pickup_result_ = *(pickup_client_.getResult());
		ROS_ERROR("The pickup action reached the time limit");
		return false;
	}

	pickup_result_ = *(pickup_client_.getResult());
	if (pickup_client_.getState() != actionlib::SimpleClientGoalState::SUCCEEDED) {
		ROS_ERROR("The pickup action has failed with result code %d", pickup_result_.manipulation_result.value);
//		mech_interface_.translateGripperCartesian(arm_name, direction_, ros::Duration(2.0), .015, .09, .02, .16, .1);
		return false;
	}

	return true;
}
std::string MoveSpline::ToString() const
{
    std::stringstream str;
    str << "MoveSpline" << std::endl;
    str << "spline Id: " << GetId() << std::endl;
    str << "flags: " << splineflags.ToString() << std::endl;
    if (splineflags.final_angle)
        str << "facing  angle: " << facing.angle;
    else if (splineflags.final_target)
        str << "facing target: " << facing.target;
    else if (splineflags.final_point)
        str << "facing  point: " << facing.f.x << " " << facing.f.y << " " << facing.f.z;
    str << std::endl;
    str << "time passed: " << time_passed << std::endl;
    str << "total  time: " << Duration() << std::endl;
    str << "spline point Id: " << point_Idx << std::endl;
    str << "path  point  Id: " << currentPathIdx() << std::endl;
    str << spline.ToString();
    return str.str();
}
Example #19
0
std::string MoveSpline::ToString() const
{
    std::stringstream str;
    str << "MoveSpline" << std::endl;
    str << "spline Id: " << GetId() << std::endl;
    str << "flags: " << splineflags.ToString() << std::endl;
    if (facing.type == MONSTER_MOVE_FACING_ANGLE)
        str << "facing  angle: " << facing.angle;
    else if (facing.type == MONSTER_MOVE_FACING_TARGET)
        str << "facing target: " << facing.target.ToString();
    else if (facing.type == MONSTER_MOVE_FACING_SPOT)
        str << "facing  point: " << facing.f.x << " " << facing.f.y << " " << facing.f.z;
    str << std::endl;
    str << "time passed: " << time_passed << std::endl;
    str << "total  time: " << Duration() << std::endl;
    str << "spline point Id: " << point_Idx << std::endl;
    str << "path  point  Id: " << currentPathIdx() << std::endl;
    str << spline.ToString();
    return str.str();
}
Example #20
0
/*
================
idEntityFx::Event_Trigger
================
*/
void idEntityFx::Event_Trigger( idEntity *activator ) {

	if ( g_skipFX.GetBool() ) {
		return;
	}

	float		fxActionDelay;
	const char *fx;

	if ( gameLocal.time < nextTriggerTime ) {
		return;
	}

	if ( spawnArgs.GetString( "fx", "", &fx) ) {
		
		//ivan start
		if( manualRemove ){ //new case
			if( started >= 0 && !manualFadeIsOn && spawnArgs.GetBool( "toggle", "0") ){ //if it is active && toggle is set
				FadeOutFx();
			}else{
				Setup( fx );
				Start( gameLocal.time ); //don't autokill
			}
		}else{ //old case
		//ivan end
			Setup( fx );
			Start( gameLocal.time );
			PostEventMS( &EV_Fx_KillFx, Duration() );
		}
		BecomeActive( TH_THINK );
	}

	fxActionDelay = spawnArgs.GetFloat( "fxActionDelay" );
	if ( fxActionDelay != 0.0f ) {
		nextTriggerTime = gameLocal.time + SEC2MS( fxActionDelay );
	} else {
		// prevent multiple triggers on same frame
		nextTriggerTime = gameLocal.time + 1;
	}
	PostEventSec( &EV_Fx_Action, fxActionDelay, activator );
}
Example #21
0
bool MythProgramInfo::IsSetup() const
{
    if (m_flags)
        return true;

    m_flags |= FLAGS_INITIALIZED;

    if (m_proginfo)
    {
        // Has Artworks ?
        for (std::vector<Myth::Artwork>::const_iterator it = m_proginfo->artwork.begin(); it != m_proginfo->artwork.end(); ++it)
        {
            if (it->type == "coverart")
                m_flags |= FLAGS_HAS_COVERART;
            else if (it->type == "fanart")
                m_flags |= FLAGS_HAS_FANART;
            else if (it->type == "banner")
                m_flags |= FLAGS_HAS_BANNER;
        }

        // Is Visible ?
        // Filter out recording of special storage group Deleted
        // Filter out recording with duration less than 5 seconds
        // When  deleting a recording, it might not be deleted immediately but marked as 'pending delete'.
        // Depending on the protocol version the recording is moved to the group Deleted or
        // the 'delete pending' flag is set
        if (Duration() >= 5)
        {
            if (RecordingGroup() == "Deleted" || IsDeletePending())
                m_flags |= FLAGS_IS_DELETED;
            else
                m_flags |= FLAGS_IS_VISIBLE;
        }

        // Is LiveTV ?
        if (RecordingGroup() == "LiveTV")
            m_flags |= FLAGS_IS_LIVETV;
    }
    return true;
}
Example #22
0
DECLARE_EXPORT void CalendarBucket::updateOffsets()
{
  if (days==127 && !starttime && endtime==Duration(86400L))
  {
    // Bucket is effective continuously. No need to update the structure.
    offsetcounter = 0;
    return;
  }

  offsetcounter = -1;
  short tmp = days;
  for (short i=0; i<=6; ++i)
  {
    // Loop over all days in the week
    if (tmp & 1)
    {
      if (offsetcounter>=1 && (offsets[offsetcounter] == 86400*i + starttime))
        // Special case: the start date of todays offset entry
        // is the end date yesterdays entry. We can just update the
        // end date of that entry.
        offsets[offsetcounter] = 86400*i + endtime;
      else
      {
        // New offset pair
        offsets[++offsetcounter] = 86400*i + starttime;
        offsets[++offsetcounter] = 86400*i + endtime;
      }
    }
    tmp = tmp>>1; // Shift to the next bit
  }

  // Special case: there is no gap between the end of the last event in the
  // week and the next event in the following week.
  if (offsetcounter >= 1 && offsets[0]==0 && offsets[offsetcounter]==86400*7)
  {
    offsets[0] = offsets[offsetcounter-1] - 86400*7;
    offsets[offsetcounter] = 86400*7 + offsets[1];
  }
}
Example #23
0
void ColumnDue::render (
  std::vector <std::string>& lines,
  Task& task,
  int width,
  Color& color)
{
  if (task.has (_name))
  {
    if (_style == "countdown")
    {
      Date date ((time_t) strtol (task.get (_name).c_str (), NULL, 10));
      Date now;

      lines.push_back (
        color.colorize (
          rightJustify (
            Duration (now - date).format (), width)));
    }
    else
      ColumnDate::render (lines, task, width, color);
  }
}
Example #24
0
void TExportZone::HandleDoubleClick(BPoint where)
{
	//	Get window bounds
	const BRect winBounds = Window()->Bounds();
	
	//	Get cue sheet bounds
	const BRect bounds = Bounds();
	
	//	Get total pixel length for bounds checking
	int32 pixelWidth = TimeToPixels( Duration(), GetCurrentTimeFormat(), GetCurrentResolution() );
	
	//	Update tracking rects
	m_InRect.left 	= bounds.left;
	m_InRect.right 	= m_InRect.left + kExportSliderWidth;

	//	Set up out rect.  Check for right side length bounds violation
	int32 outRight = (bounds.left + winBounds.Width()) - kHeaderWidth;
	if (outRight > pixelWidth)
		outRight = pixelWidth;
	
	m_OutRect.right	 = outRight;
	m_OutRect.left 	 = m_OutRect.right - kExportSliderWidth;
	
	//	Update m_ExportChannel
	m_ExportChannel.left  = m_InRect.right;
	m_ExportChannel.right = m_OutRect.left;
	
	//	Update cue sheet variables
	m_CueSheetWindow->GetCueSheetView()->SetExportStartTime( PixelsToTime(m_InRect.left, GetCurrentTimeFormat(), GetCurrentResolution()) );
	m_CueSheetWindow->GetCueSheetView()->SetExportStopTime( PixelsToTime(m_OutRect.right, GetCurrentTimeFormat(), GetCurrentResolution()) );
	
	//	Update text items
	m_CueSheetWindow->GetExportTimeView()->DrawInText();
	m_CueSheetWindow->GetExportTimeView()->DrawOutText();

	//	Redraw
	Invalidate();
}
Example #25
0
void ColumnRecur::render (
  std::vector <std::string>& lines,
  Task& task,
  int width,
  Color& color)
{
  if (_style == "default" ||
      _style == "duration")
  {
    lines.push_back (
      color.colorize (
        rightJustify (
          Duration (task.get ("recur")).formatCompact (),
          width)));
  }
  else if (_style == "indicator")
  {
    if (task.has (_name))
      lines.push_back (
        color.colorize (
          rightJustify (context.config.get ("recurrence.indicator"), width)));
  }
}
Example #26
0
static Duration operator % (const QDateTime &dt, PeriodType::Base b)
{
	switch(b)
	{
	case PeriodType::Min:
		return Duration(0, 0, 0, QTime(0, 0, dt.time().second()));
	case PeriodType::Hour:
		return Duration(0, 0, 0, QTime(0, dt.time().minute(), dt.time().second()));
	case PeriodType::Day:
		return Duration(0, 0, 0, dt.time());
	case PeriodType::Month:
		return Duration(0, 0, dt.date().day(), dt.time());
	case PeriodType::Year:
		return Duration(0, dt.date().month(), dt.date().day(), dt.time());
	default:
		return Duration();
	}
}
Example #27
0
bool Rate::sleep()
{
  Time expected_end = start_ + expected_cycle_time_;

  Time actual_end = Time::now();

  // detect backward jumps in time
  if (actual_end < start_)
  {
    expected_end = actual_end + expected_cycle_time_;
  }

  //calculate the time we'll sleep for
  Duration sleep_time = expected_end - actual_end;

  //set the actual amount of time the loop took in case the user wants to know
  actual_cycle_time_ = actual_end - start_;

  //make sure to reset our start time
  start_ = expected_end;

  //if we've taken too much time we won't sleep
  if(sleep_time <= Duration(0.0))
  {
    // if we've jumped forward in time, or the loop has taken more than a full extra
    // cycle, reset our cycle
    if (actual_end > expected_end + expected_cycle_time_)
    {
      start_ = actual_end;
    }
    // return false to show that the desired rate was not met
    return false;
  }

  return sleep_time.sleep();
}
Example #28
0
void Application::process_game()
{
	int time = 1;
	while (true)
	{
		if (time == 1)
		{
			time = 15;
		}
		else
		{
			time -= 1;
		}
		m_GUI->Timer->Update(time);
		if (time == 15)
		{
			update();
			m_GUI->DescriptionBox->add_item_control(new GUI_Text("Ход - " + std::to_string(m_game_turn) + ".", new GUI_TextFormat(10, 19, RGBA_t(0.0, 0.8, 0.0, 1.0))));
			m_game_turn += 1;
		}
		std::chrono::milliseconds Duration(250);
		std::this_thread::sleep_for(Duration);
	}
}
Example #29
0
/*
================
idEntityFx::Event_Trigger
================
*/
void idEntityFx::Event_Trigger( idEntity *activator )
{

	if( g_skipFX.GetBool() )
	{
		return;
	}
	
	float		fxActionDelay;
	const char *fx;
	
	if( gameLocal.time < nextTriggerTime )
	{
		return;
	}
	
	if( spawnArgs.GetString( "fx", "", &fx ) )
	{
		Setup( fx );
		Start( gameLocal.time );
		PostEventMS( &EV_Fx_KillFx, Duration() );
		BecomeActive( TH_THINK );
	}
	
	fxActionDelay = spawnArgs.GetFloat( "fxActionDelay" );
	if( fxActionDelay != 0.0f )
	{
		nextTriggerTime = gameLocal.time + SEC2MS( fxActionDelay );
	}
	else
	{
		// prevent multiple triggers on same frame
		nextTriggerTime = gameLocal.time + 1;
	}
	PostEventSec( &EV_Fx_Action, fxActionDelay, activator );
}
Example #30
0
void Placement::commit(const Placement& prevPlacement, TimePoint now) {
    commitTime = now;

    bool placementChanged = false;

    float increment = mapMode == MapMode::Continuous ?
        std::chrono::duration<float>(commitTime - prevPlacement.commitTime) / Duration(std::chrono::milliseconds(300)) :
        1.0;

    // add the opacities from the current placement, and copy their current values from the previous placement
    for (auto& jointPlacement : placements) {
        auto prevOpacity = prevPlacement.opacities.find(jointPlacement.first);
        if (prevOpacity != prevPlacement.opacities.end()) {
            opacities.emplace(jointPlacement.first, JointOpacityState(prevOpacity->second, increment, jointPlacement.second.text, jointPlacement.second.icon));
            placementChanged = placementChanged ||
                jointPlacement.second.icon != prevOpacity->second.icon.placed ||
                jointPlacement.second.text != prevOpacity->second.text.placed;
        } else {
            opacities.emplace(jointPlacement.first, JointOpacityState(jointPlacement.second.text, jointPlacement.second.icon, jointPlacement.second.skipFade));
            placementChanged = placementChanged || jointPlacement.second.icon || jointPlacement.second.text;
        }
    }

    // copy and update values from the previous placement that aren't in the current placement but haven't finished fading
    for (auto& prevOpacity : prevPlacement.opacities) {
        if (opacities.find(prevOpacity.first) == opacities.end()) {
            JointOpacityState jointOpacity(prevOpacity.second, increment, false, false);
            if (!jointOpacity.isHidden()) {
                opacities.emplace(prevOpacity.first, jointOpacity);
                placementChanged = placementChanged || prevOpacity.second.icon.placed || prevOpacity.second.text.placed;
            }
        }
    }

    fadeStartTime = placementChanged ? commitTime : prevPlacement.fadeStartTime;
}