/**
 * Constructor when using resource string.
 * @param display The target display.
 * @param font The font to use to render the text.
 * @param text The text itself.
 * @param width The maximum width of the text area (currently unused).
 */
FmtTextDecor::FmtTextDecor(Display &display, std::shared_ptr<Ttf> font,
                           std::shared_ptr<ResStr> text, int width) :
    display(display), font(std::move(font)), text(std::move(text)),
    width(width),
    sizeWidth(0), sizeHeight(0)
{
    Reformat();

    // Automatically trigger Reformat() when the text changes.
    this->text->SetOnReload([&]() {
        Reformat();
    });
}
void DecodedMux::Simplify(void)
{
    CheckCombineInCycle1();

    if (gRDP.otherMode.text_lod)
        ConvertLODFracTo0();

    if (g_curRomInfo.bTexture1Hack)
    {
        ReplaceVal(MUX_TEXEL1, MUX_TEXEL0, 2, MUX_MASK);
        ReplaceVal(MUX_TEXEL1, MUX_TEXEL0, 3, MUX_MASK);
    }
    Reformat(true);

    UseShadeForConstant();
    Reformat(true);

    if (m_dwShadeColorChannelFlag == MUX_0)
    {
        MergeShadeWithConstants();
        Reformat(true);
    }

#ifdef ALLOW_USE_TEXTURE_FOR_CONSTANTS
    UseTextureForConstant();
    for (int i=0; i<2; i++)
    {
        if (m_ColorTextureFlag[i] != 0)
        {
            if (m_dwShadeColorChannelFlag == m_ColorTextureFlag[i])
            {
                ReplaceVal(MUX_SHADE, MUX_TEXEL0+i, N64Cycle0RGB, MUX_MASK);
                ReplaceVal(MUX_SHADE, MUX_TEXEL0+i, N64Cycle1RGB, MUX_MASK);
                m_dwShadeColorChannelFlag = 0;
            }
            if (m_dwShadeAlphaChannelFlag == m_ColorTextureFlag[i])
            {
                ReplaceVal(MUX_SHADE, MUX_TEXEL0+i, N64Cycle0Alpha, MUX_MASK);
                ReplaceVal(MUX_SHADE, MUX_TEXEL0+i, N64Cycle1Alpha, MUX_MASK);
                ReplaceVal(MUX_SHADE|MUX_ALPHAREPLICATE, (MUX_TEXEL0+i)|MUX_ALPHAREPLICATE, N64Cycle0RGB, MUX_MASK_WITH_ALPHA);
                ReplaceVal(MUX_SHADE|MUX_ALPHAREPLICATE, (MUX_TEXEL0+i)|MUX_ALPHAREPLICATE, N64Cycle1RGB, MUX_MASK_WITH_ALPHA);
                m_dwShadeAlphaChannelFlag = 0;
            }
        }
    }
    Reformat(true);
#endif

    m_bTexel0IsUsed = IsUsed(MUX_TEXEL0, MUX_MASK);
    m_bTexel1IsUsed = IsUsed(MUX_TEXEL1, MUX_MASK);
}
示例#3
0
void DecodedMuxForOGL14V2::Simplify(void)
{
    CheckCombineInCycle1();
    if( g_curRomInfo.bTexture1Hack )
    {
        ReplaceVal(MUX_TEXEL1,MUX_TEXEL0,2);
        ReplaceVal(MUX_TEXEL1,MUX_TEXEL0,3);
    }
    Reformat();

    UseTextureForConstant();
    Reformat();

    m_bTexel0IsUsed = isUsed(MUX_TEXEL0);
    m_bTexel1IsUsed = isUsed(MUX_TEXEL1);
}
/**
 * Constructor when using static string.
 * @param display The target display.
 * @param font The font to use to render the text.
 * @param s The text itself.
 * @param width The maximum width of the text area (currently unused).
 */
FmtTextDecor::FmtTextDecor(Display &display, std::shared_ptr<Ttf> font,
                           const std::string &s, int width) :
    display(display), font(std::move(font)), s(s),
    width(width),
    sizeWidth(0), sizeHeight(0)
{
    Reformat();
}
void* AudioBufferContainer::GetAllChannels(int fmt, bool preserveData)
{
  Reformat(fmt, preserveData);
  ReLeave(true, preserveData);
  
  m_hasData = true;   // because caller may use the returned pointer to populate the container
  
  return m_data.Get();
}
/**
 * Change the text to a static string.
 * @param s The static string.
 */
void FmtTextDecor::SetText(const std::string &s)
{
    if (text) {
        text.reset();
    }
    if (this->s != s) {
        this->s = s;
        Reformat();
    }
}
示例#7
0
void ViewFilesDialog::OnFviewNext(void)
{
    // handles "next" button; also called from DoDataExchange
    ReformatHolder::ReformatPart part;
    ReformatHolder::ReformatID id;
    int result;

    if (fBusy) {
        LOGI("BUSY!");
        return;
    }

    fBusy = true;

    if (!fpSelSet->IterHasNext()) {
        ASSERT(false);
        return;
    }

    /*
     * Get the pieces of the file.
     */
    SelectionEntry* pSelEntry = fpSelSet->IterNext();
    GenericEntry* pEntry = pSelEntry->GetEntry();
    result = ReformatPrep(pEntry);
#if 0
    {
        // for debugging -- simulate failure
        result = -1;
        delete fpHolder;
        fpHolder = NULL;
        delete fpOutput;
        fpOutput = NULL;
    }
#endif

    fBusy = false;
    if (result != 0) {
        ASSERT(fpHolder == NULL);
        ASSERT(fpOutput == NULL);
        return;
    }

    /*
     * Format a piece.
     */
    ConfigurePartButtons(pSelEntry->GetEntry());
    part = GetSelectedPart();
    id = ConfigureFormatSel(part);
    Reformat(pSelEntry->GetEntry(), part, id);

    DisplayText(pSelEntry->GetEntry()->GetDisplayName());
}
void* AudioBufferContainer::GetChannel(int fmt, int chIdx, bool preserveData)
{
  Reformat(fmt, preserveData); 
  if (chIdx >= m_nCh)
  {
    Resize(chIdx+1, m_nFrames, true);
  }
  ReLeave(false, preserveData);
  
  m_hasData = true;   // because caller may use the returned pointer to populate the container
  
  int offsz = chIdx*m_nFrames*(int)fmt;
  return (unsigned char*)m_data.Get()+offsz;
}
示例#9
0
void ViewFilesDialog::ForkSelectCommon(ReformatHolder::ReformatPart part)
{
    GenericEntry* pEntry;
    ReformatHolder::ReformatID id;

    LOGI("Switching to file part=%d", part);
    ASSERT(fpHolder != NULL);
    ASSERT(fpSelSet != NULL);
    ASSERT(fpSelSet->IterCurrent() != NULL);
    pEntry = fpSelSet->IterCurrent()->GetEntry();
    ASSERT(pEntry != NULL);

    id = ConfigureFormatSel(part);

    Reformat(pEntry, part, id);
    DisplayText(pEntry->GetDisplayName());
}
示例#10
0
void ViewFilesDialog::OnFviewPrev(void)
{
    ReformatHolder::ReformatPart part;
    ReformatHolder::ReformatID id;
    int result;

    if (fBusy) {
        LOGI("BUSY!");
        return;
    }

    fBusy = true;

    if (!fpSelSet->IterHasPrev()) {
        ASSERT(false);
        return;
    }

    /*
     * Get the pieces of the file.
     */
    SelectionEntry* pSelEntry = fpSelSet->IterPrev();
    GenericEntry* pEntry = pSelEntry->GetEntry();
    result = ReformatPrep(pEntry);

    fBusy = false;
    if (result != 0) {
        ASSERT(fpHolder == NULL);
        ASSERT(fpOutput == NULL);
        return;
    }

    /*
     * Format a piece.
     */
    ConfigurePartButtons(pEntry);
    part = GetSelectedPart();
    id = ConfigureFormatSel(part);
    Reformat(pEntry, part, id);

    DisplayText(pEntry->GetDisplayName());
}
// src=NULL to memset(0)
void* AudioBufferContainer::SetAllChannels(int fmt, void* src, int nCh, int nFrames)
{
  Reformat(fmt, false);
  Resize(nCh, nFrames, false);
  
  int sz = nCh*nFrames*(int)fmt;
  void* dest = GetAllChannels(fmt, false);
  if (src)
  {
    memcpy(dest, src, sz);
  }
  else
  {
    memset(dest, 0, sz);
  }
  
  m_interleaved = true;
  m_hasData = true;  
  return dest;
}
示例#12
0
void ViewFilesDialog::OnFormatSelChange(void)
{
    /*
     * The user has changed entries in the format selection drop box.
     *
     * Also called from the "quick change" buttons.
     */

    CComboBox* pCombo = (CComboBox*) GetDlgItem(IDC_FVIEW_FORMATSEL);
    ASSERT(pCombo != NULL);
    LOGD("+++ SELECTION IS NOW %d", pCombo->GetCurSel());

    SelectionEntry* pSelEntry = fpSelSet->IterCurrent();
    GenericEntry* pEntry = pSelEntry->GetEntry();
    ReformatHolder::ReformatPart part;
    ReformatHolder::ReformatID id;

    part = GetSelectedPart();
    id = (ReformatHolder::ReformatID) pCombo->GetItemData(pCombo->GetCurSel());
    Reformat(pEntry, part, id);

    DisplayText(pEntry->GetDisplayName());
}
void* AudioBufferContainer::MixChannel(int fmt, void* src, int chIdx, int nFrames, bool addToDest, double wt_start, double wt_end)
{
  Reformat(fmt, true);
  if (nFrames > m_nFrames || chIdx >= m_nCh) 
  {
    int maxframes = (nFrames > m_nFrames ? nFrames : m_nFrames);
    Resize(chIdx+1, maxframes, true);        
  }
  
  void* dest = GetChannel(fmt, chIdx, true);
  
  if (fmt == FMT_32FP)
  {
    BufMixT((float*)dest, (float*)src, nFrames, addToDest, wt_start, wt_end);
  }
  else if (fmt == FMT_64FP)
  {
    BufMixT((double*)dest, (double*)src, nFrames, addToDest, wt_start, wt_end);
  }
  
  m_interleaved = false;
  m_hasData = true;
  return dest;
}
// src=NULL to memset(0)
void* AudioBufferContainer::SetChannel(int fmt, void* src, int chIdx, int nFrames)
{
  Reformat(fmt, true);
  if (nFrames > m_nFrames || chIdx >= m_nCh) 
  {
    int maxframes = (nFrames > m_nFrames ? nFrames : m_nFrames);
    Resize(chIdx+1, maxframes, true);        
  }
  
  int sz = nFrames*(int)fmt;
  void* dest = GetChannel(fmt, chIdx, true);
  if (src)
  {
    memcpy(dest, src, sz);
  }
  else
  {
    memset(dest, 0, sz);
  }
   
  m_interleaved = false;
  m_hasData = true;
  return dest;
}
示例#15
0
FString USetupDefinition::Format( FString Msg, const TCHAR* Other )
{
	guard(USetupDefinition::Format);
	if( Manifest )
	{
		if( Other )
		{
			Reformat( Msg, GConfig->GetSectionPrivate(Other,0,1,*(FString(MANIFEST_FILE)+TEXT(".")+UObject::GetLanguage())) );
			if( FString(UObject::GetLanguage())!=TEXT("INT") )
				Reformat( Msg, GConfig->GetSectionPrivate(Other,0,1,*(FString(MANIFEST_FILE)+TEXT(".INT"))) );
		}
		Reformat( Msg, GConfig->GetSectionPrivate(TEXT("Setup"  ),0,1,*(FString(MANIFEST_FILE)+TEXT(".")+UObject::GetLanguage())) );
		Reformat( Msg, GConfig->GetSectionPrivate(TEXT("General"),0,1,*(FString(MANIFEST_FILE)+TEXT(".")+UObject::GetLanguage())) );
		if( FString(UObject::GetLanguage())!=TEXT("INT") )
		{
			Reformat( Msg, GConfig->GetSectionPrivate(TEXT("Setup"  ),0,1,*(FString(MANIFEST_FILE)+TEXT(".INT"))) );
			Reformat( Msg, GConfig->GetSectionPrivate(TEXT("General"),0,1,*(FString(MANIFEST_FILE)+TEXT(".INT"))) );
		}
		Reformat( Msg, GConfig->GetSectionPrivate(TEXT("Setup"),0,1,*ConfigFile) );
	}
	return Msg;
	unguard;
}
示例#16
0
ctp2_Menu::Item *ctp2_Menu::CreateItem(MBCHAR *block, const MBCHAR *text, const MBCHAR *shortcut,
									   const MBCHAR *icon, void *cookie)
{
	ctp2_ListItem *item = (ctp2_ListItem *)aui_Ldl::BuildHierarchyFromRoot(block);
	Assert(item);
	if(!item)
		return NULL;

	ctp2_Menu::Item *menuItem = new ctp2_Menu::Item;
	menuItem->m_item = item;
	if(!shortcut) {
		shortcut = "";
	}

	menuItem->m_shortcut = new MBCHAR[(strlen(shortcut) + 1) * sizeof(MBCHAR)];
	strcpy(menuItem->m_shortcut, shortcut);
	menuItem->m_cookie = cookie;


	item->SetUserData(menuItem);

	ctp2_Static *box = (ctp2_Static *)menuItem->m_item->GetChildByIndex(0);
	Assert(box);
	if(!box)
		return menuItem;

	ctp2_Static *textBox = (ctp2_Static *)box->GetChildByIndex(0);
	Assert(textBox);
	if(!textBox)
		return menuItem;

	textBox->SetText(text);

	ctp2_Static *shortcutBox = (ctp2_Static *)box->GetChildByIndex(1);
	Assert(shortcutBox);
	if(!shortcutBox)
		return menuItem;

	shortcutBox->SetText(shortcut);

	m_items->AddTail(menuItem);

	if(!textBox->GetTextFont()) {
		textBox->TextReloadFont();
	}

	if(!shortcutBox->GetTextFont()) {
		shortcutBox->TextReloadFont();
	}

	if(icon) {
		Assert(box->NumChildren() > 2);
		ctp2_Static *iconBox = (ctp2_Static *)box->GetChildByIndex(2);
		Assert(iconBox);
		if(iconBox) {
			iconBox->SetImage((MBCHAR *)icon);
			iconBox->ShouldDraw(TRUE);
		}
	}

	bool resizedSomething = false;
	if(shortcutBox && shortcut) {
		sint32 width = shortcutBox->GetTextFont()->GetStringWidth(shortcut);
		if(width + k_EXTRA_SHORTCUT_WIDTH > m_maxShortcutWidth) {
			m_maxShortcutWidth = width + k_EXTRA_SHORTCUT_WIDTH;
			resizedSomething = true;
		}
	}

	Assert(textBox->GetTextFont());
	if(textBox->GetTextFont()) {
		sint32 width = textBox->GetTextFont()->GetStringWidth(text);
		if(width > m_maxTextWidth) {
			m_maxTextWidth = width;
			resizedSomething = true;
		}

		sint32 iconWidth = 0;
		sint32 iconHeight = 0;

		if(box->NumChildren() > 2) {
			ctp2_Static *iconBox = (ctp2_Static *)box->GetChildByIndex(2);
			Assert(iconBox);
			iconWidth = iconBox->GetImage()->TheSurface()->Width() + k_LEFT_ITEM_MARGIN;
			iconHeight = iconBox->GetImage()->TheSurface()->Width();
		}


		if(iconWidth > m_maxIconWidth) {
			m_maxIconWidth = iconWidth;
			resizedSomething = true;
		}

		if(iconHeight > m_maxItemHeight) {
			m_maxItemHeight = iconHeight;
			resizedSomething = true;
		}
	}

	if(item->Height() > m_maxItemHeight) {
		m_maxItemHeight = item->Height();
	}

	if(resizedSomething) {

		PointerList<Item>::Walker walk(m_items);
		while(walk.IsValid()) {
			Reformat(walk.GetObj());
			walk.Next();
		}
	} else {

		Reformat(menuItem);
	}

	return menuItem;
}