diff --git a/src/gui/wxgui/AudioDebuggerWindow.cpp b/src/gui/wxgui/AudioDebuggerWindow.cpp index ef1122a2..eb30974f 100644 --- a/src/gui/wxgui/AudioDebuggerWindow.cpp +++ b/src/gui/wxgui/AudioDebuggerWindow.cpp @@ -133,9 +133,7 @@ AudioDebuggerWindow::AudioDebuggerWindow(wxFrame& parent) { wxListItem item; item.SetId(i); - char tempStr[32]; - sprintf(tempStr, "%d", snd_core::AX_MAX_VOICES-i-1); - item.SetText(wxString(tempStr)); + item.SetText(wxString::Format("%d", snd_core::AX_MAX_VOICES-i-1)); voiceListbox->InsertItem(item); } RefreshVoiceList(); @@ -178,21 +176,15 @@ void AudioDebuggerWindow::RefreshVoiceList_sndgeneric() voiceListbox->Freeze(); - char tempStr[64]; for (sint32 i = 0; i < snd_core::AX_MAX_VOICES; i++) { sint32 voiceIndex = snd_core::AX_MAX_VOICES - 1 - i; snd_core::AXVPBInternal_t* internal = snd_core::__AXVPBInternalVoiceArray + voiceIndex; // index - sprintf(tempStr, "%d", (sint32)tempVoiceArray[voiceIndex].index); - voiceListbox->SetItem(i, 0, tempStr); + voiceListbox->SetItem(i, 0, wxString::Format("%d", (sint32)tempVoiceArray[voiceIndex].index)); // state uint16 playbackState = _swapEndianU16(internal->playbackState); - if (playbackState) - strcpy(tempStr, "on"); - else - strcpy(tempStr, "off"); - voiceListbox->SetItem(i, 1, tempStr); + voiceListbox->SetItem(i, 1, playbackState ? "on" : "off"); // if voice index is invalid then stop updating here to prevent crashes if (voiceIndex < 0 || playbackState == 0) { @@ -217,49 +209,38 @@ void AudioDebuggerWindow::RefreshVoiceList_sndgeneric() continue; } // format + wxString formatLabel; if (tempVoiceArray[voiceIndex].offsets.format == _swapEndianU16(snd_core::AX_FORMAT_ADPCM)) - strcpy(tempStr, "adpcm"); + formatLabel = "adpcm"; else if (tempVoiceArray[voiceIndex].offsets.format == _swapEndianU16(snd_core::AX_FORMAT_PCM16)) - strcpy(tempStr, "pcm16"); + formatLabel = "pcm16"; else if (tempVoiceArray[voiceIndex].offsets.format == _swapEndianU16(snd_core::AX_FORMAT_PCM8)) - strcpy(tempStr, "pcm8"); + formatLabel = "pcm8"; else - strcpy(tempStr, "ukn"); - voiceListbox->SetItem(i, 2, tempStr); + formatLabel = "ukn"; + voiceListbox->SetItem(i, 2, formatLabel); // update offsets snd_core::AXPBOFFSET_t tempOffsets; snd_core::AXGetVoiceOffsets(tempVoiceArray + voiceIndex, &tempOffsets); // sample base - sprintf(tempStr, "%08x", _swapEndianU32(tempOffsets.samples)); - voiceListbox->SetItem(i, 3, tempStr); + voiceListbox->SetItem(i, 3, wxString::Format("%08x", _swapEndianU32(tempOffsets.samples))); // current offset - sprintf(tempStr, "%08x", _swapEndianU32(tempOffsets.currentOffset)); - voiceListbox->SetItem(i, 4, tempStr); + voiceListbox->SetItem(i, 4, wxString::Format("%08x", _swapEndianU32(tempOffsets.currentOffset))); // loop offset - if (tempOffsets.loopFlag) - sprintf(tempStr, "%08x", _swapEndianU32(tempOffsets.loopOffset)); - else - sprintf(tempStr, ""); - voiceListbox->SetItem(i, 5, tempStr); + voiceListbox->SetItem(i, 5, tempOffsets.loopFlag ? wxString::Format("%08x", _swapEndianU32(tempOffsets.loopOffset)) : ""); // end offset - sprintf(tempStr, "%08x", _swapEndianU32(tempOffsets.endOffset)); - voiceListbox->SetItem(i, 6, tempStr); + voiceListbox->SetItem(i, 6, wxString::Format("%08x", _swapEndianU32(tempOffsets.endOffset))); // volume - sprintf(tempStr, "%04x", (uint16)internal->veVolume); - voiceListbox->SetItem(i, 7, tempStr); + voiceListbox->SetItem(i, 7, wxString::Format("%04x", (uint16)internal->veVolume)); // volume delta - sprintf(tempStr, "%04x", (uint16)internal->veDelta); - voiceListbox->SetItem(i, 8, tempStr); + voiceListbox->SetItem(i, 8, wxString::Format("%04x", (uint16)internal->veDelta)); // src - sprintf(tempStr, "%04x%04x", _swapEndianU16(internal->src.ratioHigh), _swapEndianU16(internal->src.ratioLow)); - voiceListbox->SetItem(i, 9, tempStr); + voiceListbox->SetItem(i, 9, wxString::Format("%04x%04x", _swapEndianU16(internal->src.ratioHigh), _swapEndianU16(internal->src.ratioLow))); // lpf if (internal->lpf.on) { - sprintf(tempStr, "%04x", _swapEndianU16(internal->lpf.a0)); - voiceListbox->SetItem(i, 10, tempStr); - sprintf(tempStr, "%04x", _swapEndianU16(internal->lpf.b0)); - voiceListbox->SetItem(i, 11, tempStr); + voiceListbox->SetItem(i, 10, wxString::Format("%04x", _swapEndianU16(internal->lpf.a0))); + voiceListbox->SetItem(i, 11, wxString::Format("%04x", _swapEndianU16(internal->lpf.b0))); } else { @@ -269,16 +250,11 @@ void AudioDebuggerWindow::RefreshVoiceList_sndgeneric() // biquad if (internal->biquad.on) { - sprintf(tempStr, "%04x", _swapEndianU16(internal->biquad.b0)); - voiceListbox->SetItem(i, 12, tempStr); - sprintf(tempStr, "%04x", _swapEndianU16(internal->biquad.b1)); - voiceListbox->SetItem(i, 13, tempStr); - sprintf(tempStr, "%04x", _swapEndianU16(internal->biquad.b2)); - voiceListbox->SetItem(i, 14, tempStr); - sprintf(tempStr, "%04x", _swapEndianU16(internal->biquad.a1)); - voiceListbox->SetItem(i, 15, tempStr); - sprintf(tempStr, "%04x", _swapEndianU16(internal->biquad.a2)); - voiceListbox->SetItem(i, 16, tempStr); + voiceListbox->SetItem(i, 12, wxString::Format("%04x", _swapEndianU16(internal->biquad.b0))); + voiceListbox->SetItem(i, 13, wxString::Format("%04x", _swapEndianU16(internal->biquad.b1))); + voiceListbox->SetItem(i, 14, wxString::Format("%04x", _swapEndianU16(internal->biquad.b2))); + voiceListbox->SetItem(i, 15, wxString::Format("%04x", _swapEndianU16(internal->biquad.a1))); + voiceListbox->SetItem(i, 16, wxString::Format("%04x", _swapEndianU16(internal->biquad.a2))); } else { @@ -288,6 +264,7 @@ void AudioDebuggerWindow::RefreshVoiceList_sndgeneric() voiceListbox->SetItem(i, 15, ""); voiceListbox->SetItem(i, 16, ""); } + wxString label; // device mix for (uint32 f = 0; f < snd_core::AX_TV_CHANNEL_COUNT*snd_core::AX_MAX_NUM_BUS; f++) { @@ -297,10 +274,10 @@ void AudioDebuggerWindow::RefreshVoiceList_sndgeneric() //debug_printf("DeviceMix TV Voice %08x b%02d/c%02d vol %04x delta %04x\n", hCPU->gpr[3], busIndex, channelIndex, _swapEndianU16(mixArrayBE[f].vol), _swapEndianU16(mixArrayBE[f].volDelta)); uint32 mixVol = internal->deviceMixTV[channelIndex * 4 + busIndex].vol; mixVol = (mixVol + 0x0FFF) >> (12); - sprintf(tempStr + f, "%x", mixVol); + label += wxString::Format("%x", mixVol); //ax.voiceInternal[voiceIndex].deviceMixTVChannel[channelIndex].bus[busIndex].vol = _swapEndianU16(mixArrayBE[f].vol); } - voiceListbox->SetItem(i, 17, tempStr); + voiceListbox->SetItem(i, 17, label); } voiceListbox->Thaw(); } diff --git a/src/gui/wxgui/MemorySearcherTool.cpp b/src/gui/wxgui/MemorySearcherTool.cpp index 75f756c7..94840363 100644 --- a/src/gui/wxgui/MemorySearcherTool.cpp +++ b/src/gui/wxgui/MemorySearcherTool.cpp @@ -393,8 +393,7 @@ void MemorySearcherTool::OnResultListClick(wxMouseEvent& event) long address = m_listResults->GetItemData(selectedIndex); auto currValue = m_listResults->GetItemText(selectedIndex, 1); - char addressString[256]; - sprintf(addressString, "0x%08lx", address); + wxString addressString = wxString::Format("0x%08lx", address); // description, address, type, value, freeze wxVector data; diff --git a/src/gui/wxgui/windows/PPCThreadsViewer/DebugPPCThreadsWindow.cpp b/src/gui/wxgui/windows/PPCThreadsViewer/DebugPPCThreadsWindow.cpp index ae1ea971..d187fbfd 100644 --- a/src/gui/wxgui/windows/PPCThreadsViewer/DebugPPCThreadsWindow.cpp +++ b/src/gui/wxgui/windows/PPCThreadsViewer/DebugPPCThreadsWindow.cpp @@ -32,18 +32,18 @@ enum wxBEGIN_EVENT_TABLE(DebugPPCThreadsWindow, wxFrame) EVT_BUTTON(CLOSE_ID, DebugPPCThreadsWindow::OnCloseButton) - EVT_BUTTON(REFRESH_ID, DebugPPCThreadsWindow::OnRefreshButton) - EVT_CLOSE(DebugPPCThreadsWindow::OnClose) -wxEND_EVENT_TABLE() + EVT_BUTTON(REFRESH_ID, DebugPPCThreadsWindow::OnRefreshButton) + EVT_CLOSE(DebugPPCThreadsWindow::OnClose) + wxEND_EVENT_TABLE() -DebugPPCThreadsWindow::DebugPPCThreadsWindow(wxFrame& parent) + DebugPPCThreadsWindow::DebugPPCThreadsWindow(wxFrame& parent) : wxFrame(&parent, wxID_ANY, _("PPC threads"), wxDefaultPosition, wxSize(930, 280), wxCLOSE_BOX | wxCLIP_CHILDREN | wxCAPTION | wxRESIZE_BORDER) { auto* sizer = new wxBoxSizer(wxVERTICAL); m_thread_list = new wxListView(this, GPLIST_ID, wxPoint(0, 0), wxSize(930, 240), wxLC_REPORT); - m_thread_list->SetFont(wxFont(8, wxFONTFAMILY_MODERN, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, false, "Courier New")); //wxSystemSettings::GetFont(wxSYS_OEM_FIXED_FONT)); + m_thread_list->SetFont(wxFont(8, wxFONTFAMILY_MODERN, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, false, "Courier New")); // wxSystemSettings::GetFont(wxSYS_OEM_FIXED_FONT)); // add columns wxListItem col0; @@ -175,96 +175,86 @@ void DebugPPCThreadsWindow::RefreshThreadList() const int scrollPos = m_thread_list->GetScrollPos(0); m_thread_list->DeleteAllItems(); - if(activeThreadCount > 0) - { - __OSLockScheduler(); - srwlock_activeThreadList.LockWrite(); - for (sint32 i = 0; i < activeThreadCount; i++) - { - MPTR threadItrMPTR = activeThread[i]; - OSThread_t* cafeThread = (OSThread_t*)memory_getPointerFromVirtualOffset(threadItrMPTR); + if (activeThreadCount > 0) + { + __OSLockScheduler(); + srwlock_activeThreadList.LockWrite(); + for (sint32 i = 0; i < activeThreadCount; i++) + { + MPTR threadItrMPTR = activeThread[i]; + OSThread_t* cafeThread = (OSThread_t*)memory_getPointerFromVirtualOffset(threadItrMPTR); - char tempStr[512]; - sprintf(tempStr, "%08X", threadItrMPTR); + wxListItem item; + item.SetId(i); + item.SetText(wxString::Format("%08X", threadItrMPTR)); + m_thread_list->InsertItem(item); + m_thread_list->SetItemData(item, (long)threadItrMPTR); + // entry point + m_thread_list->SetItem(i, 1, wxString::Format("%08X", cafeThread->entrypoint.GetMPTR())); + // stack base (low) + m_thread_list->SetItem(i, 2, wxString::Format("%08X - %08X", cafeThread->stackEnd.GetMPTR(), cafeThread->stackBase.GetMPTR())); + // pc + RPLStoredSymbol* symbol = rplSymbolStorage_getByAddress(cafeThread->context.srr0); + wxString pcLabel; + if (symbol) + pcLabel = wxString::Format("%s (0x%08x)", (const char*)symbol->symbolName, cafeThread->context.srr0); + else + pcLabel = wxString::Format("%08X", cafeThread->context.srr0); + m_thread_list->SetItem(i, 3, pcLabel); + // lr + m_thread_list->SetItem(i, 4, wxString::Format("%08X", _swapEndianU32(cafeThread->context.lr))); + // state + OSThread_t::THREAD_STATE threadState = cafeThread->state; + wxString threadStateStr = "UNDEFINED"; + if (cafeThread->suspendCounter != 0) + threadStateStr = "SUSPENDED"; + else if (threadState == OSThread_t::THREAD_STATE::STATE_NONE) + threadStateStr = "NONE"; + else if (threadState == OSThread_t::THREAD_STATE::STATE_READY) + threadStateStr = "READY"; + else if (threadState == OSThread_t::THREAD_STATE::STATE_RUNNING) + threadStateStr = "RUNNING"; + else if (threadState == OSThread_t::THREAD_STATE::STATE_WAITING) + threadStateStr = "WAITING"; + else if (threadState == OSThread_t::THREAD_STATE::STATE_MORIBUND) + threadStateStr = "MORIBUND"; + m_thread_list->SetItem(i, 5, threadStateStr); + // affinity + uint8 affinity = cafeThread->attr & 7; + uint8 affinityReal = cafeThread->context.affinity; + wxString affinityLabel; + if (affinity != affinityReal) + affinityLabel = wxString::Format("(!) %d%d%d real: %d%d%d", (affinity >> 0) & 1, (affinity >> 1) & 1, (affinity >> 2) & 1, (affinityReal >> 0) & 1, (affinityReal >> 1) & 1, (affinityReal >> 2) & 1); + else + affinityLabel = wxString::Format("%d%d%d", (affinity >> 0) & 1, (affinity >> 1) & 1, (affinity >> 2) & 1); + m_thread_list->SetItem(i, 6, affinityLabel); + // priority + sint32 effectivePriority = cafeThread->effectivePriority; + m_thread_list->SetItem(i, 7, wxString::Format("%d", effectivePriority)); + // last awake in cycles + uint64 lastWakeUpTime = cafeThread->wakeUpTime; + m_thread_list->SetItem(i, 8, wxString::Format("%" PRIu64, lastWakeUpTime)); + // awake time in cycles + uint64 awakeTime = cafeThread->totalCycles; + m_thread_list->SetItem(i, 9, wxString::Format("%" PRIu64, awakeTime)); + // thread name + const char* threadName = "NULL"; + if (!cafeThread->threadName.IsNull()) + threadName = cafeThread->threadName.GetPtr(); + m_thread_list->SetItem(i, 10, threadName); + // GPR + m_thread_list->SetItem(i, 11, wxString::Format("r3 %08x r4 %08x r5 %08x r6 %08x r7 %08x", _r(3), _r(4), _r(5), _r(6), _r(7))); + // waiting condition / extra info + coreinit::OSMutex* mutex = cafeThread->waitingForMutex; + wxString extraInfoLabel; + if (mutex) + extraInfoLabel = wxString::Format("Mutex 0x%08x (Held by thread 0x%08X Lock-Count: %d)", memory_getVirtualOffsetFromPointer(mutex), mutex->owner.GetMPTR(), (uint32)mutex->lockCount); + // OSSetThreadCancelState + if (cafeThread->requestFlags & OSThread_t::REQUEST_FLAG_CANCEL) + extraInfoLabel += "[Cancel requested]"; - wxListItem item; - item.SetId(i); - item.SetText(tempStr); - m_thread_list->InsertItem(item); - m_thread_list->SetItemData(item, (long)threadItrMPTR); - // entry point - sprintf(tempStr, "%08X", cafeThread->entrypoint.GetMPTR()); - m_thread_list->SetItem(i, 1, tempStr); - // stack base (low) - sprintf(tempStr, "%08X - %08X", cafeThread->stackEnd.GetMPTR(), cafeThread->stackBase.GetMPTR()); - m_thread_list->SetItem(i, 2, tempStr); - // pc - RPLStoredSymbol* symbol = rplSymbolStorage_getByAddress(cafeThread->context.srr0); - if (symbol) - sprintf(tempStr, "%s (0x%08x)", (const char*)symbol->symbolName, cafeThread->context.srr0); - else - sprintf(tempStr, "%08X", cafeThread->context.srr0); - m_thread_list->SetItem(i, 3, tempStr); - // lr - sprintf(tempStr, "%08X", _swapEndianU32(cafeThread->context.lr)); - m_thread_list->SetItem(i, 4, tempStr); - // state - OSThread_t::THREAD_STATE threadState = cafeThread->state; - wxString threadStateStr = "UNDEFINED"; - if (cafeThread->suspendCounter != 0) - threadStateStr = "SUSPENDED"; - else if (threadState == OSThread_t::THREAD_STATE::STATE_NONE) - threadStateStr = "NONE"; - else if (threadState == OSThread_t::THREAD_STATE::STATE_READY) - threadStateStr = "READY"; - else if (threadState == OSThread_t::THREAD_STATE::STATE_RUNNING) - threadStateStr = "RUNNING"; - else if (threadState == OSThread_t::THREAD_STATE::STATE_WAITING) - threadStateStr = "WAITING"; - else if (threadState == OSThread_t::THREAD_STATE::STATE_MORIBUND) - threadStateStr = "MORIBUND"; - m_thread_list->SetItem(i, 5, threadStateStr); - // affinity - uint8 affinity = cafeThread->attr&7; - uint8 affinityReal = cafeThread->context.affinity; - if(affinity != affinityReal) - sprintf(tempStr, "(!) %d%d%d real: %d%d%d", (affinity >> 0) & 1, (affinity >> 1) & 1, (affinity >> 2) & 1, (affinityReal >> 0) & 1, (affinityReal >> 1) & 1, (affinityReal >> 2) & 1); - else - sprintf(tempStr, "%d%d%d", (affinity >> 0) & 1, (affinity >> 1) & 1, (affinity >> 2) & 1); - m_thread_list->SetItem(i, 6, tempStr); - // priority - sint32 effectivePriority = cafeThread->effectivePriority; - sprintf(tempStr, "%d", effectivePriority); - m_thread_list->SetItem(i, 7, tempStr); - // last awake in cycles - uint64 lastWakeUpTime = cafeThread->wakeUpTime; - sprintf(tempStr, "%" PRIu64, lastWakeUpTime); - m_thread_list->SetItem(i, 8, tempStr); - // awake time in cycles - uint64 awakeTime = cafeThread->totalCycles; - sprintf(tempStr, "%" PRIu64, awakeTime); - m_thread_list->SetItem(i, 9, tempStr); - // thread name - const char* threadName = "NULL"; - if (!cafeThread->threadName.IsNull()) - threadName = cafeThread->threadName.GetPtr(); - m_thread_list->SetItem(i, 10, threadName); - // GPR - sprintf(tempStr, "r3 %08x r4 %08x r5 %08x r6 %08x r7 %08x", _r(3), _r(4), _r(5), _r(6), _r(7)); - m_thread_list->SetItem(i, 11, tempStr); - // waiting condition / extra info - coreinit::OSMutex* mutex = cafeThread->waitingForMutex; - if (mutex) - sprintf(tempStr, "Mutex 0x%08x (Held by thread 0x%08X Lock-Count: %d)", memory_getVirtualOffsetFromPointer(mutex), mutex->owner.GetMPTR(), (uint32)mutex->lockCount); - else - sprintf(tempStr, ""); - - // OSSetThreadCancelState - if (cafeThread->requestFlags & OSThread_t::REQUEST_FLAG_CANCEL) - strcat(tempStr, "[Cancel requested]"); - - m_thread_list->SetItem(i, 12, tempStr); + m_thread_list->SetItem(i, 12, extraInfoLabel); if (selected_thread != 0 && selected_thread == (long)threadItrMPTR) { @@ -388,7 +378,7 @@ void DebugPPCThreadsWindow::ProfileThread(OSThread_t* thread) void DebugPPCThreadsWindow::OnThreadListPopupClick(wxCommandEvent& evt) { - MPTR threadMPTR = (MPTR)(size_t) static_cast(evt.GetEventObject())->GetClientData(); + MPTR threadMPTR = (MPTR)(size_t)static_cast(evt.GetEventObject())->GetClientData(); OSThread_t* osThread = (OSThread_t*)memory_getPointerFromVirtualOffset(threadMPTR); __OSLockScheduler(); if (!coreinit::__OSIsThreadActive(osThread)) diff --git a/src/gui/wxgui/windows/TextureRelationViewer/TextureRelationWindow.cpp b/src/gui/wxgui/windows/TextureRelationViewer/TextureRelationWindow.cpp index cc1e3321..52f9b19e 100644 --- a/src/gui/wxgui/windows/TextureRelationViewer/TextureRelationWindow.cpp +++ b/src/gui/wxgui/windows/TextureRelationViewer/TextureRelationWindow.cpp @@ -171,173 +171,153 @@ void TextureRelationViewerWindow::OnClose(wxCloseEvent& event) void TextureRelationViewerWindow::_setTextureRelationListItemTexture(wxListCtrl* uiList, sint32 rowIndex, struct LatteTextureInformation* texInfo) { - char tempStr[512]; + wxString typeLabel; // count number of alternative views for base view sint32 alternativeViewCount = texInfo->alternativeViewCount; if (texInfo->isUpdatedOnGPU) - sprintf(tempStr, "TEXTURE*"); + typeLabel = "TEXTURE*"; else - sprintf(tempStr, "TEXTURE"); + typeLabel = "TEXTURE"; if (alternativeViewCount > 0) { - sprintf(tempStr + strlen(tempStr), "(%d)", alternativeViewCount + 1); + typeLabel += wxString::Format("(%d)", alternativeViewCount + 1); } wxListItem item; item.SetId(rowIndex); - item.SetText(tempStr); + item.SetText(typeLabel); item.SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW)); uiList->InsertItem(item); sint32 columnIndex = 1; // phys address - sprintf(tempStr, "%08X", texInfo->physAddress); - uiList->SetItem(rowIndex, columnIndex, tempStr); + uiList->SetItem(rowIndex, columnIndex, wxString::Format("%08X", texInfo->physAddress)); columnIndex++; // phys mip address - sprintf(tempStr, "%08X", texInfo->physMipAddress); - uiList->SetItem(rowIndex, columnIndex, tempStr); + uiList->SetItem(rowIndex, columnIndex, wxString::Format("%08X", texInfo->physMipAddress)); columnIndex++; // dim + wxString dimLabel; if (texInfo->dim == Latte::E_DIM::DIM_2D) - strcpy(tempStr, "2D"); + dimLabel = "2D"; else if (texInfo->dim == Latte::E_DIM::DIM_2D_ARRAY) - strcpy(tempStr, "2D_ARRAY"); + dimLabel = "2D_ARRAY"; else if (texInfo->dim == Latte::E_DIM::DIM_3D) - strcpy(tempStr, "3D"); + dimLabel = "3D"; else if (texInfo->dim == Latte::E_DIM::DIM_CUBEMAP) - strcpy(tempStr, "CUBEMAP"); + dimLabel = "CUBEMAP"; else if (texInfo->dim == Latte::E_DIM::DIM_1D) - strcpy(tempStr, "1D"); + dimLabel = "1D"; else if (texInfo->dim == Latte::E_DIM::DIM_2D_MSAA) - strcpy(tempStr, "2D_MSAA"); + dimLabel = "2D_MSAA"; else if (texInfo->dim == Latte::E_DIM::DIM_2D_ARRAY_MSAA) - strcpy(tempStr, "2D_MS_ARRAY"); + dimLabel = "2D_MS_ARRAY"; else - strcpy(tempStr, "UKN"); - uiList->SetItem(rowIndex, columnIndex, tempStr); + dimLabel = "UKN"; + uiList->SetItem(rowIndex, columnIndex, dimLabel); columnIndex++; // resolution + wxString resolutionLabel; if (texInfo->depth == 1) - sprintf(tempStr, "%dx%d", texInfo->width, texInfo->height); + resolutionLabel = wxString::Format("%dx%d", texInfo->width, texInfo->height); else - sprintf(tempStr, "%dx%dx%d", texInfo->width, texInfo->height, texInfo->depth); - uiList->SetItem(rowIndex, columnIndex, tempStr); + resolutionLabel = wxString::Format("%dx%dx%d", texInfo->width, texInfo->height, texInfo->depth); + uiList->SetItem(rowIndex, columnIndex, resolutionLabel); columnIndex++; // format + wxString formatLabel; if(texInfo->isDepth) - sprintf(tempStr, "%04x(d)", (uint32)texInfo->format); + formatLabel = wxString::Format("%04x(d)", (uint32)texInfo->format); else - sprintf(tempStr, "%04x", (uint32)texInfo->format); - uiList->SetItem(rowIndex, columnIndex, tempStr); + formatLabel = wxString::Format("%04x", (uint32)texInfo->format); + uiList->SetItem(rowIndex, columnIndex, formatLabel); columnIndex++; // pitch - sprintf(tempStr, "%d", texInfo->pitch); - uiList->SetItem(rowIndex, columnIndex, tempStr); + uiList->SetItem(rowIndex, columnIndex, wxString::Format("%d", texInfo->pitch)); columnIndex++; // tilemode - sprintf(tempStr, "%d", (int)texInfo->tileMode); - uiList->SetItem(rowIndex, columnIndex, tempStr); + uiList->SetItem(rowIndex, columnIndex, wxString::Format("%d", (int)texInfo->tileMode)); columnIndex++; // sliceRange - sprintf(tempStr, ""); - uiList->SetItem(rowIndex, columnIndex, tempStr); + uiList->SetItem(rowIndex, columnIndex, ""); columnIndex++; // mipRange - if(texInfo->mipLevels == 1) - sprintf(tempStr, "1 mip"); - else - sprintf(tempStr, "%d mips", texInfo->mipLevels); - uiList->SetItem(rowIndex, columnIndex, tempStr); + uiList->SetItem(rowIndex, columnIndex, texInfo->mipLevels == 1 ? "1 mip" : wxString::Format("%d mips", texInfo->mipLevels)); columnIndex++; // last access - sprintf(tempStr, "%ds", (GetTickCount() - texInfo->lastAccessTick + 499) / 1000); - uiList->SetItem(rowIndex, columnIndex, tempStr); + uiList->SetItem(rowIndex, columnIndex, wxString::Format("%lus", (GetTickCount() - texInfo->lastAccessTick + 499) / 1000)); columnIndex++; // overwrite resolution - strcpy(tempStr, ""); + wxString overwriteResLabel; if (texInfo->overwriteInfo.hasResolutionOverwrite) { if(texInfo->overwriteInfo.depth != 1 || texInfo->depth != 1) - sprintf(tempStr, "%dx%dx%d", texInfo->overwriteInfo.width, texInfo->overwriteInfo.height, texInfo->overwriteInfo.depth); + overwriteResLabel = wxString::Format("%dx%dx%d", texInfo->overwriteInfo.width, texInfo->overwriteInfo.height, texInfo->overwriteInfo.depth); else - sprintf(tempStr, "%dx%d", texInfo->overwriteInfo.width, texInfo->overwriteInfo.height); + overwriteResLabel = wxString::Format("%dx%d", texInfo->overwriteInfo.width, texInfo->overwriteInfo.height); } - uiList->SetItem(rowIndex, columnIndex, tempStr); + uiList->SetItem(rowIndex, columnIndex, overwriteResLabel); columnIndex++; } void TextureRelationViewerWindow::_setTextureRelationListItemView(wxListCtrl* uiList, sint32 rowIndex, struct LatteTextureInformation* texInfo, struct LatteTextureViewInformation* viewInfo) { - char tempStr[512]; // count number of alternative views sint32 alternativeViewCount = 0; // todo // set type string - if(alternativeViewCount == 0) - sprintf(tempStr, "> VIEW"); - else - sprintf(tempStr, "> VIEW(%d)", alternativeViewCount+1); // find and handle highlight entry wxListItem item; item.SetId(rowIndex); - item.SetText(tempStr); + item.SetText(alternativeViewCount == 0 ? "> VIEW" : wxString::Format("> VIEW(%d)", alternativeViewCount+1)); item.SetBackgroundColour(wxHelper::CalculateAccentColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW))); uiList->InsertItem(item); //uiList->SetItemPtrData(item, (wxUIntPtr)viewInfo); sint32 columnIndex = 1; // phys address - sprintf(tempStr, ""); - uiList->SetItem(rowIndex, columnIndex, tempStr); + uiList->SetItem(rowIndex, columnIndex, ""); columnIndex++; // phys mip address - sprintf(tempStr, ""); - uiList->SetItem(rowIndex, columnIndex, tempStr); + uiList->SetItem(rowIndex, columnIndex, ""); columnIndex++; // dim + wxString dimLabel; if (viewInfo->dim == Latte::E_DIM::DIM_2D) - strcpy(tempStr, "2D"); + dimLabel = "2D"; else if (viewInfo->dim == Latte::E_DIM::DIM_2D_ARRAY) - strcpy(tempStr, "2D_ARRAY"); + dimLabel = "2D_ARRAY"; else if (viewInfo->dim == Latte::E_DIM::DIM_3D) - strcpy(tempStr, "3D"); + dimLabel = "3D"; else if (viewInfo->dim == Latte::E_DIM::DIM_CUBEMAP) - strcpy(tempStr, "CUBEMAP"); + dimLabel = "CUBEMAP"; else if (viewInfo->dim == Latte::E_DIM::DIM_1D) - strcpy(tempStr, "1D"); + dimLabel = "1D"; else if (viewInfo->dim == Latte::E_DIM::DIM_2D_MSAA) - strcpy(tempStr, "2D_MSAA"); + dimLabel = "2D_MSAA"; else if (viewInfo->dim == Latte::E_DIM::DIM_2D_ARRAY_MSAA) - strcpy(tempStr, "2D_ARRAY_MSAA"); + dimLabel = "2D_ARRAY_MSAA"; else - strcpy(tempStr, "UKN"); - uiList->SetItem(rowIndex, columnIndex, tempStr); + dimLabel = "UKN"; + uiList->SetItem(rowIndex, columnIndex, dimLabel); columnIndex++; // resolution - tempStr[0] = '\0'; - uiList->SetItem(rowIndex, columnIndex, tempStr); + uiList->SetItem(rowIndex, columnIndex, ""); columnIndex++; // format - sprintf(tempStr, "%04x", (uint32)viewInfo->format); - uiList->SetItem(rowIndex, columnIndex, tempStr); + uiList->SetItem(rowIndex, columnIndex, wxString::Format("%04x", (uint32)viewInfo->format)); columnIndex++; // pitch - tempStr[0] = '\0'; - uiList->SetItem(rowIndex, columnIndex, tempStr); + uiList->SetItem(rowIndex, columnIndex, ""); columnIndex++; // tilemode - tempStr[0] = '\0'; - uiList->SetItem(rowIndex, columnIndex, tempStr); + uiList->SetItem(rowIndex, columnIndex, ""); columnIndex++; // sliceRange - sprintf(tempStr, "%d-%d", viewInfo->firstSlice, viewInfo->firstSlice+ viewInfo->numSlice-1); - uiList->SetItem(rowIndex, columnIndex, tempStr); + uiList->SetItem(rowIndex, columnIndex, wxString::Format("%d-%d", viewInfo->firstSlice, viewInfo->firstSlice+ viewInfo->numSlice-1)); columnIndex++; // mipRange - sprintf(tempStr, "%d-%d", viewInfo->firstMip, viewInfo->firstMip + viewInfo->numMip - 1); - uiList->SetItem(rowIndex, columnIndex, tempStr); + uiList->SetItem(rowIndex, columnIndex, wxString::Format("%d-%d", viewInfo->firstMip, viewInfo->firstMip + viewInfo->numMip - 1)); columnIndex++; // last access - tempStr[0] = '\0'; - uiList->SetItem(rowIndex, columnIndex, tempStr); + uiList->SetItem(rowIndex, columnIndex, ""); columnIndex++; }