Exemplo n.º 1
0
void RecvItemDoorOpenClose( int cn, t_item_door_open_close *p )
{
	LPITEMLIST i;
	int item_id = p->item_id;

	if( item_id < 0 ) return;
	if( item_id >= MAX_ITEM_LIST ) return;

	i = &ItemList[ item_id ];

	if( (i->attr[ IATTR_ATTR] & IA2_DOOR) == 0 ) return; // 문이 아니네...

	if( p->openclose == 0 ) // 열어주세요..
	{
		if( i->attr[ IATTR_ATTR] & IA2_OPENED ) return; // 열려 있으면 리턴.
		//
		// 여기서 connections[cn].chrslt가  열수 있는지 검사한다.
		//
		i->attr[ IATTR_ATTR] |= IA2_OPENED;

		SetArea( CHANGE_IA2_ATTR_ITEM_AREA, item_id );
	}
	else // 닫아주세요.
	{
		if( (i->attr[ IATTR_ATTR] & IA2_OPENED) == 0 ) return; // 닫혀 있으면 리턴.
		//
		// 여기서 connections[cn].chrslt가  닫을수 있는지 검사한다.
		//
		i->attr[ IATTR_ATTR] &= (~(IA2_OPENED) );

		SetArea( CHANGE_IA2_ATTR_ITEM_AREA, item_id );
	}
}
Exemplo n.º 2
0
void SubtitleScreen::OptimiseDisplayedArea(void)
{
    if (!m_refreshArea)
        return;

    QRegion visible;
    QListIterator<MythUIType *> i(m_ChildrenList);
    while (i.hasNext())
    {
        MythUIType *img = i.next();
        visible = visible.united(img->GetArea());
    }

    if (visible.isEmpty())
        return;

    QRect bounding  = visible.boundingRect();
    bounding = bounding.translated(m_safeArea.topLeft());
    bounding = m_safeArea.intersected(bounding);
    int left = m_safeArea.left() - bounding.left();
    int top  = m_safeArea.top()  - bounding.top();
    SetArea(MythRect(bounding));

    i.toFront();;
    while (i.hasNext())
    {
        MythUIType *img = i.next();
        img->SetArea(img->GetArea().translated(left, top));
    }
}
Exemplo n.º 3
0
/**
 *  \copydoc MythUIType::ParseElement()
 */
bool MythScreenType::ParseElement(
    const QString &filename, QDomElement &element, bool showWarnings)
{
    if (element.tagName() == "area")
    {
        MythRect rect = parseRect(element, false);
        MythRect rectN = parseRect(element);
        QRect screenArea = GetMythMainWindow()->GetUIScreenRect();

        if (rect.x() == -1)
            rectN.moveLeft((screenArea.width() - rectN.width()) / 2);

        if (rect.y() == -1)
            rectN.moveTop((screenArea.height() - rectN.height()) / 2);

        SetArea(rectN);

        if (m_Area.width() < screenArea.width() ||
            m_Area.height() < screenArea.height())
        {
            m_FullScreen = false;
        }
        else
        {
            m_FullScreen = true;
        }
    }
    else
    {
        return MythUIType::ParseElement(filename, element, showWarnings);
    }

    return true;
}
Exemplo n.º 4
0
void PathDetect::FindLargest(cv::Mat& watershedImage) const
{
    int rows = watershedImage.rows;
    int cols = watershedImage.cols;

    cv::Mat image = watershedImage.clone();
    cv::Point bestPoint;
    int bestPixelCount = 0;
    int areaCount = 0;
    for (int r = 0; r < rows; ++r)
    {
        for (int c = 0; c < cols; ++c)
        {
            cv::Point currentPoint(c, r);
            if (image.at<unsigned char>(currentPoint) == PATH)
            {
                areaCount++;
                int pixelCount = FloodArea(image, currentPoint, 1);
                if (pixelCount > bestPixelCount)
                {
                    bestPixelCount = pixelCount;
                    bestPoint = currentPoint;
                }
            }
        }
    }

    FloodArea(watershedImage, bestPoint, 1);
    SetArea(watershedImage, 1, PATH);
}
Exemplo n.º 5
0
/**
 *  \brief Copy this widgets state from another.
 */
void MythUIType::CopyFrom(MythUIType *base)
{
    m_Visible = base->m_Visible;
    m_Enabled = base->m_Enabled;
    m_CanHaveFocus = base->m_CanHaveFocus;
    m_focusOrder = base->m_focusOrder;

    SetArea(base->m_Area);
    m_MinArea = base->m_MinArea;
    m_MinSize = base->m_MinSize;
    m_Alpha = base->m_Alpha;
    m_AlphaChangeMode = base->m_AlphaChangeMode;
    m_AlphaChange = base->m_AlphaChange;
    m_AlphaMin = base->m_AlphaMin;
    m_AlphaMax = base->m_AlphaMax;

    m_Moving = base->m_Moving;
    m_XYDestination = base->m_XYDestination;
    m_XYSpeed = base->m_XYSpeed;
    m_deferload = base->m_deferload;

    QList<MythUIType *>::Iterator it;
    for (it = base->m_ChildrenList.begin(); it != base->m_ChildrenList.end();
         ++it)
    {
        MythUIType *child = GetChild((*it)->objectName());
        if (child)
            child->CopyFrom(*it);
        else
            (*it)->CreateCopy(this);
    }
}
Exemplo n.º 6
0
/**
 *  \brief Parse the xml definition of this widget setting the state of the
 *         object accordingly
 */
bool MythUIType::ParseElement(
    const QString &filename, QDomElement &element, bool showWarnings)
{
    //FIXME add movement etc.

    if (element.tagName() == "position")
        SetPosition(parsePoint(element));
    else if (element.tagName() == "area")
    {
        SetArea(parseRect(element));
    }
    else if (element.tagName() == "minsize")
    {
        // Use parsePoint so percentages can be used
        if (element.hasAttribute("initiator"))
            m_Initiator = parseBool(element.attribute("initiator"));

        if (element.hasAttribute("vanish"))
            m_Vanish = parseBool(element.attribute("vanish"));

        SetMinSize(parsePoint(element));
    }
    else if (element.tagName() == "alpha")
    {
        m_Alpha = getFirstText(element).toInt();
        m_AlphaChangeMode = 0;
    }
    else if (element.tagName() == "alphapulse")
    {
        m_AlphaChangeMode = 2;
        m_AlphaMin = element.attribute("min", "0").toInt();
        m_Alpha = m_AlphaMax = element.attribute("max", "255").toInt();

        if (m_AlphaMax > 255)
            m_Alpha = m_AlphaMax = 255;

        if (m_AlphaMin < 0)
            m_AlphaMin = 0;

        m_AlphaChange = element.attribute("change", "5").toInt();
    }
    else if (element.tagName() == "focusorder")
    {
        int order = getFirstText(element).toInt();
        SetFocusOrder(order);
    }
    else if (element.tagName() == "loadondemand")
    {
        SetDeferLoad(parseBool(element));
    }
    else if (element.tagName() == "helptext")
    {
        m_helptext = getFirstText(element);
    }
    else
        return false;

    return true;
}
Exemplo n.º 7
0
void SubtitleScreen::DisableForcedSubtitles(void)
{
    if (kDisplayNone != m_subtitleType)
        return;
    ClearAllSubtitles();
    SetVisible(false);
    SetArea(MythRect());
}
Exemplo n.º 8
0
bool SrSetArea(HANDLE hCom, bool bSave, unsigned char cData,
		unsigned int *pdwErr) {
	int ret = SetArea(hCom, (unsigned char) bSave, cData, pdwErr);
	if (ret == -1) {
		*pdwErr = ERR_CODE_SET_AREA;
		return false;
	}
	return true;
}
Exemplo n.º 9
0
  void Teleporter::Init (
    const yap::ID& mapWorldID,
    const yap::Vector2& mapPoint,
    const yap::FloatRect& area)
  {
    SetMapWorldID (mapWorldID);
    SetMapPoint (mapPoint);

    SetArea (area);
  }
Exemplo n.º 10
0
void Address::View()
{

	ParishCheck(Parish);
	SetParish(Parish[25]);
	AreaCheck(Area);
	SetArea(Area[10]);
	cin.getline(Street,40);
	SetStreet(Street[40]);

}
Exemplo n.º 11
0
void cTrueColorDemo::Show(void)
{
  osd = cOsdProvider::NewOsd(cOsd::OsdLeft(), cOsd::OsdTop());
  if (osd) {
     if (SetArea()) {
        osd->DrawRectangle(0, 0, osd->Width() - 1, osd->Height() - 1, clrGray50);
        osd->Flush();
        Start();
        }
     }
}
Exemplo n.º 12
0
void TeletextScreen::OptimiseDisplayedArea(void)
{
    VideoOutput *vo = m_player->GetVideoOutput();
    if (!vo)
        return;
    MythPainter *osd_painter = vo->GetOSDPainter();
    if (!osd_painter)
        return;

    QHashIterator<int, QImage*> it(m_rowImages);
    while (it.hasNext())
    {
        it.next();
        MythImage* image = osd_painter->GetFormatImage();
        if (!image || !it.value())
            continue;

        int row = it.key();
        image->Assign(*(it.value()));
        MythUIImage *uiimage = new MythUIImage(this, QString("ttrow%1")
                                                        .arg(row));
        if (uiimage)
        {
            uiimage->SetImage(image);
            uiimage->SetArea(MythRect(0, row * m_rowHeight,
                                      m_safeArea.width(), m_rowHeight * 2));
        }
    }

    QRegion visible;
    QListIterator<MythUIType *> i(m_ChildrenList);
    while (i.hasNext())
    {
        MythUIType *img = i.next();
        visible = visible.united(img->GetArea());
    }

    if (visible.isEmpty())
        return;

    QRect bounding  = visible.boundingRect();
    bounding = bounding.translated(m_safeArea.topLeft());
    bounding = m_safeArea.intersected(bounding);
    int left = m_safeArea.left() - bounding.left();
    int top  = m_safeArea.top()  - bounding.top();
    SetArea(MythRect(bounding));

    i.toFront();;
    while (i.hasNext())
    {
        MythUIType *img = i.next();
        img->SetArea(img->GetArea().translated(left, top));
    }
}
Exemplo n.º 13
0
MythUISimpleText::MythUISimpleText(const QString &text,
                                   const MythFontProperties &font,
                                   const QRect & rect, Qt::Alignment align,
                                   MythUIType *parent, const QString &name)
    : MythUIType(parent, name),
      m_Justification(align),
      m_Font(font),
      m_Message(text.trimmed())
{
    SetArea(rect);
    m_Font = font;
}
Exemplo n.º 14
0
void InteractiveScreen::UpdateArea(void)
{
    if (m_ChildrenList.isEmpty())
    {
        m_safeArea = QRect();
    }
    else if (m_player && m_player->getVideoOutput())
    {
        float tmp = 0.0;
        QRect dummy;
        m_player->getVideoOutput()->GetOSDBounds(dummy, m_safeArea, tmp, tmp, tmp);
    }
    SetArea(MythRect(m_safeArea));
}
Exemplo n.º 15
0
void SubtitleScreen::EnableSubtitles(int type, bool forced_only)
{
    if (forced_only)
    {
        SetVisible(true);
        SetArea(MythRect());
        return;
    }

    m_subtitleType = type;
    if (m_subreader)
    {
        m_subreader->EnableAVSubtitles(kDisplayAVSubtitle == m_subtitleType);
        m_subreader->EnableTextSubtitles(kDisplayTextSubtitle == m_subtitleType);
        m_subreader->EnableRawTextSubtitles(kDisplayRawTextSubtitle == m_subtitleType);
    }
    if (m_608reader)
        m_608reader->SetEnabled(kDisplayCC608 == m_subtitleType);
    if (m_708reader)
        m_708reader->SetEnabled(kDisplayCC708 == m_subtitleType);
    ClearAllSubtitles();
    SetVisible(m_subtitleType != kDisplayNone);
    SetArea(MythRect());
}
Exemplo n.º 16
0
eOSState cTrueColorDemo::ProcessKey(eKeys Key)
{
  eOSState state = cOsdObject::ProcessKey(Key);
  if (state == osUnknown) {
     LOCK_PIXMAPS;
     LOCK_THREAD;
     const int d = 80;
     switch (Key & ~k_Repeat) {
       case kUp:     cursor.SetY(max(cursorLimits.Top(),    cursor.Y() - d)); clockwise = false; break;
       case kDown:   cursor.SetY(min(cursorLimits.Bottom(), cursor.Y() + d)); clockwise = true; break;
       case kLeft:   cursor.SetX(max(cursorLimits.Left(),   cursor.X() - d)); clockwise = false; break;
       case kRight:  cursor.SetX(min(cursorLimits.Right(),  cursor.X() + d)); clockwise = true; break;
       case kRed:    if (destroyablePixmap) {
                        osd->DestroyPixmap(destroyablePixmap);
                        destroyablePixmap = NULL;
                        }
                     break;
       case kGreen:  if (toggleablePixmap)
                        toggleablePixmap->SetLayer(-toggleablePixmap->Layer());
                     break;
       case k1:      Cancel(3);
                     SetArea();
                     DrawEllipses(osd);
                     break;
       case k2:      Cancel(3);
                     SetArea();
                     DrawSlopes(osd);
                     break;
       case kBack:
       case kOk:     return osEnd;
       default: return state;
       }
     state = osContinue;
     }
  return state;
}
Exemplo n.º 17
0
MythUIText::MythUIText(const QString &text, const MythFontProperties &font,
                       QRect displayRect, QRect altDisplayRect,
                       MythUIType *parent, const QString &name)
    : MythUIType(parent, name),
      m_Justification(Qt::AlignLeft | Qt::AlignTop),
      m_OrigDisplayRect(displayRect), m_AltDisplayRect(altDisplayRect),
      m_Canvas(0, 0, displayRect.width(), displayRect.height()),
      m_drawRect(displayRect),        m_cursorPos(-1, -1),
      m_Message(text.trimmed()),
      m_CutMessage(""),               m_DefaultMessage(text),
      m_Cutdown(Qt::ElideRight),      m_Font(new MythFontProperties()),
      m_colorCycling(false),          m_startColor(),
      m_endColor(),                   m_numSteps(0),
      m_curStep(0),
      curR(0.0),      curG(0.0),      curB(0.0),
      incR(0.0),      incG(0.0),      incB(0.0)
{
#if 0 // Not currently used
    m_usingAltArea = false;
#endif
    m_ShrinkNarrow = true;
    m_MultiLine = false;

    m_scrollStartDelay = m_scrollReturnDelay = ScrollBounceDelay;
    m_scrollPause = 0;
    m_scrollForwardRate = m_scrollReturnRate =
                              70.0 / MythMainWindow::drawRefresh;
    m_scrollBounce = false;
    m_scrollOffset = 0;
    m_scrollPos = 0;
    m_scrollPosWhole = 0;
    m_scrollDirection = ScrollNone;
    m_scrolling = false;

    m_textCase = CaseNormal;
    m_Ascent = m_Descent = m_leftBearing = m_rightBearing = 0;
    m_Leading = 1;
    m_extraLeading = 0;
    m_lineHeight = 0;
    m_textCursor = -1;
    m_EnableInitiator = true;

    SetArea(displayRect);
    m_FontStates.insert("default", font);
    *m_Font = m_FontStates["default"];
}
Exemplo n.º 18
0
bool TriangleGradPulse::Prepare  (const PrepareMode mode) {

	bool btag = true;

	ATTRIBUTE("Amplitude", m_amplitude );

	UNOBSERVABLE_ATTRIBUTE("TriangleType");

	if ( mode != PREP_UPDATE) {
		if (!HasDOMattribute("Duration") ) {
			m_duration  = ( fabs(m_amplitude)>0.0 ? fabs(m_amplitude)/m_slew_rate : 1e-5 );
		} else {
			if (m_duration  < (m_amplitude/m_slew_rate) && mode == PREP_VERBOSE)
				cout << "Warning in in TRIANGLEGRADPULSE " << GetName()
					 << "duration too short (slew-rate conflict)" << endl;
		}
	}

	SetArea( 0.5*m_amplitude*GetDuration() );

	btag = ( GradPulse::Prepare(mode) && btag );

	if ( mode != PREP_UPDATE) {
		if (HasDOMattribute("TriangleType") ) {
			string type = GetDOMattribute("TriangleType");
			if (type == "UP") m_triangle_type = TRIANGLE_UP;
			if (type == "DN") m_triangle_type = TRIANGLE_DN;
		} else {
			AddDOMattribute("TriangleType","UP");
		}
	}

    if (!btag && mode == PREP_VERBOSE)
        cout << "\n warning in Prepare(1) of TRAPGRADPULSE " << GetName() << endl;

    if (mode != PREP_UPDATE) {
		HideAttribute("Area"           );
		HideAttribute("MaxAmpl",  false);
		HideAttribute("SlewRate", false);
	}

	return btag;

}
Exemplo n.º 19
0
bool MythUITextEdit::ParseElement(
    const QString &filename, QDomElement &element, bool showWarnings)
{
    bool parsed = true;

    if (element.tagName() == "area")
    {
        SetArea(parseRect(element));
    }
    else if (element.tagName() == "keyboardposition")
    {
        QString pos = getFirstText(element);

        if (pos == "aboveedit")
            m_keyboardPosition = VK_POSABOVEEDIT;
        else if (pos == "belowedit")
            m_keyboardPosition = VK_POSBELOWEDIT;
        else if (pos == "screentop")
            m_keyboardPosition = VK_POSTOPDIALOG;
        else if (pos == "screenbottom")
            m_keyboardPosition = VK_POSBOTTOMDIALOG;
        else if (pos == "screencenter")
            m_keyboardPosition = VK_POSCENTERDIALOG;
        else
        {
            VERBOSE_XML(VB_GENERAL, LOG_ERR, filename, element,
                        QString("Unknown popup position '%1'").arg(pos));
            m_keyboardPosition = VK_POSBELOWEDIT;
        }
    }
    else
    {
        return MythUIType::ParseElement(filename, element, showWarnings);
    }

    return parsed;
}
Exemplo n.º 20
0
MythUIText::MythUIText(const QString &text, const MythFontProperties &font,
                       QRect displayRect, QRect altDisplayRect,
                       MythUIType *parent, const QString &name)
           : MythUIType(parent, name),
             m_Justification(Qt::AlignLeft | Qt::AlignTop),
             m_OrigDisplayRect(displayRect), m_AltDisplayRect(altDisplayRect),
             m_drawRect(displayRect),        m_Message(text.trimmed()),
             m_CutMessage(""),               m_DefaultMessage(text),
             m_Cutdown(true),                m_Font(new MythFontProperties()),
             m_colorCycling(false),          m_startColor(),
             m_endColor(),                   m_numSteps(0),
             m_curStep(0),
             curR(0.0),      curG(0.0),      curB(0.0),
             incR(0.0),      incG(0.0),      incB(0.0)
{
    m_MultiLine = false;
    m_scrolling = false;
    m_scrollDirection = ScrollLeft;
    m_textCase = CaseNormal;

    SetArea(displayRect);
    m_FontStates.insert("default", font);
    *m_Font = m_FontStates["default"];
}
Exemplo n.º 21
0
bool MythUIText::ParseElement(
    const QString &filename, QDomElement &element, bool showWarnings)
{
    if (element.tagName() == "area")
    {
        SetArea(parseRect(element));
        m_OrigDisplayRect = m_Area;
    }
//    else if (element.tagName() == "altarea") // Unused, but maybe in future?
//        m_AltDisplayRect = parseRect(element);
    else if (element.tagName() == "font")
    {
        QString fontname = getFirstText(element);
        MythFontProperties *fp = GetFont(fontname);
        if (!fp)
            fp = GetGlobalFontMap()->GetFont(fontname);
        if (fp)
        {
            MythFontProperties font = *fp;
            int screenHeight = GetMythMainWindow()->GetUIScreenRect().height();
            font.Rescale(screenHeight);
            int fontStretch = GetMythUI()->GetFontStretch();
            font.AdjustStretch(fontStretch);
            QString state = element.attribute("state","");
            if (!state.isEmpty())
            {
                m_FontStates.insert(state, font);
            }
            else
            {
                m_FontStates.insert("default", font);
                *m_Font = m_FontStates["default"];
            }
        }
    }
    else if (element.tagName() == "value")
    {
        if (element.attribute("lang","").isEmpty())
        {
            m_Message = qApp->translate("ThemeUI",
                                        parseText(element).toUtf8(), NULL,
                                        QCoreApplication::UnicodeUTF8);
        }
		#if 0
        else if (element.attribute("lang","").toLower() ==
                 gCoreContext->GetLanguageAndVariant())
        #else
		else if (element.attribute("lang","").toLower() ==
                 "en_us")
	 #endif
        {
            m_Message = parseText(element);
        }
	 #if 0
        else if (element.attribute("lang","").toLower() ==
                 gCoreContext->GetLanguage())
	#else
		else if (element.attribute("lang","").toLower() ==
                 "en")
	#endif
        {
            m_Message = parseText(element);
        }

        m_DefaultMessage = m_Message;
        SetText(m_Message);
    }
    else if (element.tagName() == "template")
Exemplo n.º 22
0
bool MythUIText::ParseElement(
    const QString &filename, QDomElement &element, bool showWarnings)
{
    if (element.tagName() == "area")
    {
        SetArea(parseRect(element));
        m_OrigDisplayRect = m_Area;
    }
//    else if (element.tagName() == "altarea") // Unused, but maybe in future?
//        m_AltDisplayRect = parseRect(element);
    else if (element.tagName() == "font")
    {
        QString fontname = getFirstText(element);
        MythFontProperties *fp = GetFont(fontname);
        if (!fp)
            fp = GetGlobalFontMap()->GetFont(fontname);
        if (fp)
        {
            MythFontProperties font = *fp;
            int screenHeight = GetMythMainWindow()->GetUIScreenRect().height();
            font.Rescale(screenHeight);
            int fontStretch = GetMythUI()->GetFontStretch();
            font.AdjustStretch(fontStretch);
            QString state = element.attribute("state","");
            if (!state.isEmpty())
            {
                m_FontStates.insert(state, font);
            }
            else
            {
                m_FontStates.insert("default", font);
                *m_Font = m_FontStates["default"];
            }
        }
    }
    else if (element.tagName() == "value")
    {
        if (element.attribute("lang","").isEmpty())
        {
            m_Message = qApp->translate("ThemeUI",
                                        parseText(element).toUtf8(), NULL,
                                        QCoreApplication::UnicodeUTF8);
        }
        else if (element.attribute("lang","").toLower() ==
                 gCoreContext->GetLanguageAndVariant())
        {
            m_Message = parseText(element);
        }
        else if (element.attribute("lang","").toLower() ==
                 gCoreContext->GetLanguage())
        {
            m_Message = parseText(element);
        }

        m_DefaultMessage = m_Message;
        SetText(m_Message);
    }
    else if (element.tagName() == "template")
    {
        m_TemplateText = parseText(element);
    }
    else if (element.tagName() == "cutdown")
    {
        SetCutDown(parseBool(element));
    }
    else if (element.tagName() == "multiline")
    {
        SetMultiLine(parseBool(element));
    }
    else if (element.tagName() == "align")
    {
        QString align = getFirstText(element).toLower();
        SetJustification(parseAlignment(align));
    }
    else if (element.tagName() == "colorcycle")
    {
        if (GetPainter()->SupportsAnimation())
        {
            QString tmp = element.attribute("start");
            if (!tmp.isEmpty())
                m_startColor = QColor(tmp);
            tmp = element.attribute("end");
            if (!tmp.isEmpty())
                m_endColor = QColor(tmp);
            tmp = element.attribute("steps");
            if (!tmp.isEmpty())
                m_numSteps = tmp.toInt();

            // initialize the rest of the stuff
            CycleColor(m_startColor, m_endColor, m_numSteps);
        }
        else
            m_colorCycling = false;

        m_colorCycling = parseBool(element.attribute("disable"));
    }
    else if (element.tagName() == "scroll")
    {
        if (GetPainter()->SupportsAnimation())
        {
            QString tmp = element.attribute("direction");
            if (!tmp.isEmpty())
            {
                tmp = tmp.toLower();
                if (tmp == "left")
                    m_scrollDirection = ScrollLeft;
                else if (tmp == "right")
                    m_scrollDirection = ScrollRight;
                else if (tmp == "up")
                    m_scrollDirection = ScrollUp;
                else if (tmp == "down")
                    m_scrollDirection = ScrollDown;
            }

            m_scrolling = true;
        }
        else
            m_scrolling = false;
    }
    else if (element.tagName() == "case")
    {
        QString stringCase = getFirstText(element).toLower();
        if (stringCase == "lower")
            m_textCase = CaseLower;
        else if (stringCase == "upper")
            m_textCase = CaseUpper;
        else if (stringCase == "capitalisefirst")
            m_textCase = CaseCapitaliseFirst;
        else  if (stringCase == "capitaliseall")
            m_textCase = CaseCapitaliseAll;
        else
            m_textCase = CaseNormal;
        FillCutMessage();
    }
    else
    {
        return MythUIType::ParseElement(filename, element, showWarnings);
    }

    return true;
}
Exemplo n.º 23
0
 void EnclosedRenderableContainerWidget::SetActualSize(const Vector2& Size)
 {
     RelSize = Size / ParentScreen->GetViewportDimensions();
     SetArea(Size);
 }
Exemplo n.º 24
0
void BDOverlayScreen::DisplayBDOverlay(BDOverlay *overlay)
{
    if (!overlay || !m_player)
        return;

    if (!overlay->m_data)
    {
        m_overlayArea = overlay->m_position;
        SetArea(MythRect(m_overlayArea));
        DeleteAllChildren();
        m_overlayMap.clear();
        SetRedraw();
        LOG(VB_PLAYBACK, LOG_INFO, LOC +
            QString("Initialised Size: %1x%2 (%3+%4) Plane: %5 Pts: %6")
                .arg(overlay->m_position.width())
                .arg(overlay->m_position.height())
                .arg(overlay->m_position.left())
                .arg(overlay->m_position.top())
                .arg(overlay->m_plane)
                .arg(overlay->m_pts));
        BDOverlay::DeleteOverlay(overlay);
        return;
    }

    if (!m_overlayArea.isValid())
    {
        LOG(VB_GENERAL, LOG_ERR, LOC +
            "Error: Overlay image submitted before initialisation.");
    }

    VideoOutput *vo = m_player->GetVideoOutput();
    if (!vo)
        return;

    QRect   rect = overlay->m_position;
    QString hash = QString("%1+%2+%3x%4")
                    .arg(rect.left()).arg(rect.top())
                    .arg(rect.width()).arg(rect.height());

    // remove if we already have this overlay
    if (m_overlayMap.contains(hash))
    {
        LOG(VB_PLAYBACK, LOG_DEBUG, LOC + QString("Removing %1 (%2 left)")
            .arg(hash).arg(m_overlayMap.size()));
        MythUIImage *old = m_overlayMap.take(hash);
        DeleteChild(old);
    }

    // convert the overlay palette to ARGB
    uint32_t *origpalette = (uint32_t *)(overlay->m_palette);
    QVector<unsigned int> palette;
    for (int i = 0; i < 256; i++)
    {
        int y  = (origpalette[i] >> 0) & 0xff;
        int cr = (origpalette[i] >> 8) & 0xff;
        int cb = (origpalette[i] >> 16) & 0xff;
        int a  = (origpalette[i] >> 24) & 0xff;
        int r  = int(y + 1.4022 * (cr - 128));
        int b  = int(y + 1.7710 * (cb - 128));
        int g  = int(1.7047 * y - (0.1952 * b) - (0.5647 * r));
        if (r < 0) r = 0;
        if (g < 0) g = 0;
        if (b < 0) b = 0;
        if (r > 0xff) r = 0xff;
        if (g > 0xff) g = 0xff;
        if (b > 0xff) b = 0xff;
        palette.push_back((a << 24) | (r << 16) | (g << 8) | b);
    }

    // convert the image to QImage
    QImage img(rect.size(), QImage::Format_Indexed8);
    memcpy(img.bits(), overlay->m_data, rect.width() * rect.height());
    img.setColorTable(palette);
    img.convertToFormat(QImage::Format_ARGB32);

    // add to screen
    QRect scaled = vo->GetImageRect(rect);
    if (scaled.size() != rect.size())
    {
        img = img.scaled(scaled.width(), scaled.height(),
                         Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
    }

    MythPainter *osd_painter = vo->GetOSDPainter();
    MythImage* image = NULL;
    if (osd_painter)
         image = osd_painter->GetFormatImage();

    if (image)
    {
        image->Assign(img);
        MythUIImage *uiimage = new MythUIImage(this, "bdoverlay");
        if (uiimage)
        {
            uiimage->SetImage(image);
            uiimage->SetArea(MythRect(scaled));
            m_overlayMap.insert(hash, uiimage);
            LOG(VB_PLAYBACK, LOG_DEBUG, LOC + QString("Added %1 (%2 tot)")
                .arg(hash).arg(m_overlayMap.size()));
        }
    }

    SetRedraw();
    BDOverlay::DeleteOverlay(overlay);
}
Exemplo n.º 25
0
/**
 *  \copydoc MythUIType::ParseElement()
 */
bool MythUIImage::ParseElement(
    const QString &filename, QDomElement &element, bool showWarnings)
{
    QWriteLocker updateLocker(&d->m_UpdateLock);
    if (element.tagName() == "filename")
    {
        m_OrigFilename = m_Filename = getFirstText(element);
        if (m_Filename.endsWith('/'))
        {
            QDir imageDir(m_Filename);
            if (!imageDir.exists())
            {
                QString themeDir = GetMythUI()->GetThemeDir() + '/';
                imageDir = themeDir + m_Filename;
            }
            QStringList imageTypes;

            QList< QByteArray > exts = QImageReader::supportedImageFormats();
            QList< QByteArray >::Iterator it = exts.begin();
            for (;it != exts.end();++it)
            {
                imageTypes.append( QString("*.").append(*it) );
            }

            imageDir.setNameFilters(imageTypes);

            QStringList imageList = imageDir.entryList();
            srand(time(NULL));
            QString randFile;
            if (imageList.size())
                randFile = QString("%1%2").arg(m_Filename)
                           .arg(imageList.takeAt(rand() % imageList.size()));
            m_OrigFilename = m_Filename = randFile;
        }
    }
    else if (element.tagName() == "filepattern")
    {
        m_OrigFilename = m_Filename = getFirstText(element);
        QString tmp = element.attribute("low");
        if (!tmp.isEmpty())
            m_LowNum = tmp.toInt();
        tmp = element.attribute("high");
        if (!tmp.isEmpty())
            m_HighNum = tmp.toInt();
        tmp = element.attribute("cycle", "start");
        if (tmp == "reverse")
            m_animationCycle = kCycleReverse;
    }
    else if (element.tagName() == "area")
    {
        SetArea(parseRect(element));
        m_ForceSize = m_Area.size();
    }
    else if (element.tagName() == "preserveaspect")
        m_preserveAspect = parseBool(element);
    else if (element.tagName() == "crop")
        m_cropRect = parseRect(element);
    else if (element.tagName() == "delay")
    {
        QString value = getFirstText(element);
        if (value.contains(","))
        {
            QVector<int> delays;
            QStringList tokens = value.split(",");
            QStringList::iterator it = tokens.begin();
            for (; it != tokens.end(); ++it)
            {
                if ((*it).isEmpty())
                {
                    if (delays.size())
                        delays.append(delays[delays.size()-1]);
                    else
                        delays.append(0); // Default 0ms delay before first image
                }
                else
                {
                    delays.append((*it).toInt());
                }
            }

            if (delays.size())
            {
                m_Delay = delays[0];
                SetDelays(delays);
            }
        }
        else
        {
            m_Delay = value.toInt();
        }
    }
    else if (element.tagName() == "reflection")
    {
        m_isReflected = true;
        QString tmp = element.attribute("axis");
        if (!tmp.isEmpty())
        {
            if (tmp.toLower() == "horizontal")
                m_reflectAxis = ReflectHorizontal;
            else
                m_reflectAxis = ReflectVertical;
        }
        tmp = element.attribute("shear");
        if (!tmp.isEmpty())
            m_reflectShear = tmp.toInt();
        tmp = element.attribute("scale");
        if (!tmp.isEmpty())
            m_reflectScale = tmp.toInt();
        tmp = element.attribute("length");
        if (!tmp.isEmpty())
            m_reflectLength = tmp.toInt();
        tmp = element.attribute("spacing");
        if (!tmp.isEmpty())
            m_reflectSpacing = tmp.toInt();
    }
    else if (element.tagName() == "mask")
    {
        QString maskfile = getFirstText(element);
        if (m_maskImage)
        {
            m_maskImage->DownRef();
            m_maskImage = NULL;
        }

        m_maskImage = GetPainter()->GetFormatImage();
        m_maskImage->UpRef();
        if (m_maskImage->Load(maskfile))
            m_isMasked = true;
        else
        {
            m_maskImage->DownRef();
            m_maskImage = NULL;
            m_isMasked = false;
        }
    }
    else if (element.tagName() == "grayscale" ||
             element.tagName() == "greyscale")
    {
        m_isGreyscale = parseBool(element);
    }
    else
    {
        return MythUIType::ParseElement(filename, element, showWarnings);
    }

    m_NeedLoad = true;

    if (m_Parent && m_Parent->IsDeferredLoading(true))
        m_NeedLoad = false;

    return true;
}
Exemplo n.º 26
0
/**
 *  \copydoc MythUIType::ParseElement()
 */
bool MythUIImage::ParseElement(
    const QString &filename, QDomElement &element, bool showWarnings)
{
    QWriteLocker updateLocker(&d->m_UpdateLock);

    if (element.tagName() == "filename")
    {
        m_imageProperties.isThemeImage = true; // This is an image distributed with the them
        m_OrigFilename = m_imageProperties.filename = getFirstText(element);

        if (m_imageProperties.filename.endsWith('/'))
        {
            m_showingRandomImage = true;
            m_imageDirectory = m_imageProperties.filename;

            FindRandomImage();
        }
    }
    else if (element.tagName() == "filepattern")
    {
        m_imageProperties.isThemeImage = true; // This is an image distributed with the theme
        m_OrigFilename = m_imageProperties.filename = getFirstText(element);
        QString tmp = element.attribute("low");

        if (!tmp.isEmpty())
            m_LowNum = tmp.toInt();

        tmp = element.attribute("high");

        if (!tmp.isEmpty())
            m_HighNum = tmp.toInt();

        tmp = element.attribute("cycle", "start");

        if (tmp == "reverse")
            m_animationCycle = kCycleReverse;
    }
    else if (element.tagName() == "area")
    {
        SetArea(parseRect(element));
        m_imageProperties.forceSize = m_Area.size();
    }
    else if (element.tagName() == "preserveaspect")
        m_imageProperties.preserveAspect = parseBool(element);
    else if (element.tagName() == "crop")
        m_imageProperties.cropRect = parseRect(element);
    else if (element.tagName() == "delay")
    {
        QString value = getFirstText(element);

        if (value.contains(","))
        {
            QVector<int> delays;
            QStringList tokens = value.split(",");
            QStringList::iterator it = tokens.begin();

            for (; it != tokens.end(); ++it)
            {
                if ((*it).isEmpty())
                {
                    if (delays.size())
                        delays.append(delays[delays.size()-1]);
                    else
                        delays.append(0); // Default 0ms delay before first image
                }
                else
                {
                    delays.append((*it).toInt());
                }
            }

            if (delays.size())
            {
                m_Delay = delays[0];
                SetDelays(delays);
            }
        }
        else
        {
            m_Delay = value.toInt();
        }
    }
    else if (element.tagName() == "reflection")
    {
        m_imageProperties.isReflected = true;
        QString tmp = element.attribute("axis");

        if (!tmp.isEmpty())
        {
            if (tmp.toLower() == "horizontal")
                m_imageProperties.reflectAxis = ReflectHorizontal;
            else
                m_imageProperties.reflectAxis = ReflectVertical;
        }

        tmp = element.attribute("shear");

        if (!tmp.isEmpty())
            m_imageProperties.reflectShear = tmp.toInt();

        tmp = element.attribute("scale");

        if (!tmp.isEmpty())
            m_imageProperties.reflectScale = tmp.toInt();

        tmp = element.attribute("length");

        if (!tmp.isEmpty())
            m_imageProperties.reflectLength = tmp.toInt();

        tmp = element.attribute("spacing");

        if (!tmp.isEmpty())
            m_imageProperties.reflectSpacing = tmp.toInt();
    }
    else if (element.tagName() == "mask")
    {
        QString maskfile = getFirstText(element);

        MythImage *newMaskImage = GetPainter()->GetFormatImage();
        if (newMaskImage->Load(maskfile))
        {
            float wmult; // Width multipler
            float hmult; // Height multipler
            GetMythUI()->GetScreenSettings(wmult, hmult);
            if (wmult != 1.0f || hmult != 1.0f)
            {
                int width = newMaskImage->size().width() * wmult;
                int height = newMaskImage->size().height() * hmult;
                newMaskImage->Resize(QSize(width, height));
            }

            m_imageProperties.SetMaskImage(newMaskImage);
        }
        else
            m_imageProperties.SetMaskImage(NULL);
        newMaskImage->DecrRef();
    }
    else if (element.tagName() == "grayscale" ||
             element.tagName() == "greyscale")
    {
        m_imageProperties.isGreyscale = parseBool(element);
    }
    else
    {
        return MythUIType::ParseElement(filename, element, showWarnings);
    }

    m_NeedLoad = true;

    if (m_Parent && m_Parent->IsDeferredLoading(true))
        m_NeedLoad = false;

    return true;
}
Exemplo n.º 27
0
// 1207 KHS	
void CheckItemTimeElapsed( void )
{	
	static DWORD time;
	static int count;
	int s,e;

	
	if( g_curr_time < time )  return;
	time = g_curr_time + 3;
	
	if( count >= MAX_ITEM_LIST ) count = 0;
	s = count;
	count += ( MAX_ITEM_LIST/ 10 );
	e = count;
	if( e >= MAX_ITEM_LIST ) e = MAX_ITEM_LIST;		// 한번에 MAX_ITEM_LIST/3정도만 Check한다. 서버 부담을 줄이기 위해.
	
	for( int m = s ; m < e ; m ++)
	{
		if( ItemList[m].bAlive == 0 ) continue;
	
		unsigned int attr2 = ItemList[m].attr[ IATTR_ATTR];
		if( (attr2 & IA2_BOX) | (attr2 & IA2_DOOR) )
		{
			if( GetAttr2( attr2, IA2_BOX ) && GetAttr2( attr2, IA2_OPENED ) ) 
			{
				if( time > ItemList[m].attr[ IATTR_LIMIT] ) // 깨진뒤 얼마간의 시간이 지났다. 
				{
					ItemList[m].attr[ IATTR_ATTR] = IA2_BOX;
					SetArea( CHANGE_IA2_ATTR_ITEM_AREA, m );
					continue;
				}
			}
		}
	
		if( attr2 & IA2_FARM0 )
		{
			if( ItemList[m].attr[IATTR_DURATION] < g_curr_time )
			{
				ItemList[m].attr[IATTR_ATTR ] &= ~(IA2_FARM0);
				ItemList[m].attr[IATTR_ATTR ] |= IA2_FARM1;
				ItemList[m].attr[IATTR_DURATION ] = g_curr_time + 60;
				SetArea( CHANGE_IA2_ATTR_ITEM_AREA, m );
				SetArea( CHANGE_IA2_DURATION_ITEM_AREA, m );
			}
		}

		if( attr2 & IA2_FARM1 )
		{
			if( ItemList[m].attr[IATTR_DURATION] < g_curr_time )
			{
				ItemList[m].attr[IATTR_ATTR ] &= ~(IA2_FARM1);
				ItemList[m].attr[IATTR_ATTR ] |= IA2_FARM2;
				ItemList[m].attr[IATTR_DURATION ] = g_curr_time + 60;
				SetArea( CHANGE_IA2_ATTR_ITEM_AREA, m );
				SetArea( CHANGE_IA2_DURATION_ITEM_AREA, m );
			}
		}

		if( attr2 & IA2_FARM2 )
		{
			if( ItemList[m].attr[IATTR_DURATION] < g_curr_time )
			{
				ItemList[m].attr[IATTR_ATTR ] &= ~(IA2_FARM2);
				ItemList[m].attr[IATTR_ATTR ] |= IA2_FARM3;
				ItemList[m].attr[IATTR_DURATION ] = g_curr_time + 60;
				SetArea( CHANGE_IA2_ATTR_ITEM_AREA, m );
				SetArea( CHANGE_IA2_DURATION_ITEM_AREA, m );
			}
		}

		if( attr2 & IA2_FARM2 )
		{
			if( ItemList[m].attr[IATTR_DURATION] < g_curr_time )
			{
				ItemList[m].attr[IATTR_ATTR ] &= ~(IA2_FARM2);
				ItemList[m].attr[IATTR_ATTR ] |= IA2_FARM3;
				ItemList[m].attr[IATTR_DURATION ] = g_curr_time + 60;
				SetArea( CHANGE_IA2_ATTR_ITEM_AREA, m );
				SetArea( CHANGE_IA2_DURATION_ITEM_AREA, m );
			}
		}

		if( attr2 & IA2_FARM3 )
		{
			if( ItemList[m].attr[IATTR_DURATION] < g_curr_time )
			{
				ItemList[m].attr[IATTR_ATTR ] &= ~(IA2_FARM3);
				ItemList[m].attr[IATTR_ATTR ] |= IA2_FARM4;
				ItemList[m].attr[IATTR_DURATION ] = g_curr_time + 60;
				SetArea( CHANGE_IA2_ATTR_ITEM_AREA, m );
				SetArea( CHANGE_IA2_DURATION_ITEM_AREA, m );
			}
		}


		if( attr2 & IA2_FIRE )
		{
			if( ItemList[m].attr[IATTR_DURATION] < g_curr_time )
			{
				ItemList[m].bAlive = REMOVE_;
				SetArea( REMOVE_ITEM_AREA, m );
			}
		}
	}
}
Exemplo n.º 28
0
Battle::Cell::Cell(s32 ii) : index(ii), object(0), direction(UNKNOWN), quality(0), troop(NULL)
{
    SetArea(Rect());
}