asset directories, part 10

This commit is contained in:
tildearrow 2023-05-16 13:41:08 -05:00
parent b1e2d76ce6
commit 4195046283
4 changed files with 109 additions and 88 deletions

View File

@ -354,6 +354,71 @@ void FurnaceGUI::insListItem(int i, int dir, int asset) {
ImGui::PopStyleColor();
}
void FurnaceGUI::waveListItem(int i, float* wavePreview, int dir, int asset) {
DivWavetable* wave=e->song.wave[i];
for (int i=0; i<wave->len; i++) {
wavePreview[i]=wave->data[i];
}
if (wave->len>0) wavePreview[wave->len]=wave->data[wave->len-1];
if (ImGui::Selectable(fmt::sprintf("%d##_WAVE%d\n",i,i).c_str(),curWave==i)) {
curWave=i;
}
if (wantScrollList && curWave==i) ImGui::SetScrollHereY();
if (ImGui::IsItemHovered()) {
if (ImGui::IsMouseDoubleClicked(ImGuiMouseButton_Left)) {
waveEditOpen=true;
nextWindow=GUI_WINDOW_WAVE_EDIT;
}
}
ImGui::SameLine();
PlotNoLerp(fmt::sprintf("##_WAVEP%d",i).c_str(),wavePreview,wave->len+1,0,NULL,0,wave->max);
}
void FurnaceGUI::sampleListItem(int i, int dir, int asset) {
bool memWarning=false;
DivSample* sample=e->song.sample[i];
for (int j=0; j<e->song.systemLen; j++) {
DivDispatch* dispatch=e->getDispatch(j);
if (dispatch==NULL) continue;
for (int k=0; k<DIV_MAX_SAMPLE_TYPE; k++) {
if (dispatch->getSampleMemCapacity(k)==0) continue;
if (!dispatch->isSampleLoaded(k,i) && sample->renderOn[k][j]) {
memWarning=true;
break;
}
}
if (memWarning) break;
}
if (memWarning) ImGui::PushStyleColor(ImGuiCol_Text,uiColors[GUI_COLOR_SAMPLE_CHIP_WARNING]);
if (ImGui::Selectable(fmt::sprintf("%d: %s##_SAM%d",i,sample->name,i).c_str(),curSample==i)) {
curSample=i;
samplePos=0;
updateSampleTex=true;
}
if (ImGui::IsItemHovered() && !mobileUI) {
ImGui::PushStyleColor(ImGuiCol_Text,uiColors[GUI_COLOR_TEXT]);
ImGui::SetTooltip("Bank %d: %s",i/12,sampleNote[i%12]);
if (ImGui::IsMouseDoubleClicked(ImGuiMouseButton_Left)) {
sampleEditOpen=true;
nextWindow=GUI_WINDOW_SAMPLE_EDIT;
}
ImGui::PopStyleColor();
}
if (memWarning) {
ImGui::SameLine();
ImGui::Text(ICON_FA_EXCLAMATION_TRIANGLE);
if (ImGui::IsItemHovered() && !mobileUI) {
ImGui::PushStyleColor(ImGuiCol_Text,uiColors[GUI_COLOR_TEXT]);
ImGui::SetTooltip("out of memory for this sample!");
ImGui::PopStyleColor();
}
ImGui::PopStyleColor();
}
if (wantScrollList && curSample==i) ImGui::SetScrollHereY();
}
void FurnaceGUI::drawInsList(bool asChild) {
if (nextWindow==GUI_WINDOW_INS_LIST) {
insListOpen=true;
@ -600,7 +665,7 @@ void FurnaceGUI::drawInsList(bool asChild) {
DRAG_TARGET(dirIndex,-1,e->song.insDir);
if (ImGui::BeginPopupContextItem(popupID.c_str())) {
if (ImGui::MenuItem("rename...")) {
ImGui::OpenPopup("NewInsFolder");
editStr(&i.name);
}
if (ImGui::MenuItem("delete")) {
dirToDelete=dirIndex;
@ -910,73 +975,16 @@ void FurnaceGUI::drawSampleList(bool asChild) {
void FurnaceGUI::actualWaveList() {
float wavePreview[257];
for (int i=0; i<(int)e->song.wave.size(); i++) {
DivWavetable* wave=e->song.wave[i];
for (int i=0; i<wave->len; i++) {
wavePreview[i]=wave->data[i];
}
if (wave->len>0) wavePreview[wave->len]=wave->data[wave->len-1];
ImGui::TableNextRow();
ImGui::TableNextColumn();
if (ImGui::Selectable(fmt::sprintf("%d##_WAVE%d\n",i,i).c_str(),curWave==i)) {
curWave=i;
}
if (wantScrollList && curWave==i) ImGui::SetScrollHereY();
if (ImGui::IsItemHovered()) {
if (ImGui::IsMouseDoubleClicked(ImGuiMouseButton_Left)) {
waveEditOpen=true;
nextWindow=GUI_WINDOW_WAVE_EDIT;
}
}
ImGui::SameLine();
PlotNoLerp(fmt::sprintf("##_WAVEP%d",i).c_str(),wavePreview,wave->len+1,0,NULL,0,wave->max);
waveListItem(i,wavePreview,-1,-1);
}
}
void FurnaceGUI::actualSampleList() {
for (int i=0; i<(int)e->song.sample.size(); i++) {
bool memWarning=false;
DivSample* sample=e->song.sample[i];
ImGui::TableNextRow();
ImGui::TableNextColumn();
for (int j=0; j<e->song.systemLen; j++) {
DivDispatch* dispatch=e->getDispatch(j);
if (dispatch==NULL) continue;
for (int k=0; k<DIV_MAX_SAMPLE_TYPE; k++) {
if (dispatch->getSampleMemCapacity(k)==0) continue;
if (!dispatch->isSampleLoaded(k,i) && sample->renderOn[k][j]) {
memWarning=true;
break;
}
}
if (memWarning) break;
}
if (memWarning) ImGui::PushStyleColor(ImGuiCol_Text,uiColors[GUI_COLOR_SAMPLE_CHIP_WARNING]);
if (ImGui::Selectable(fmt::sprintf("%d: %s##_SAM%d",i,sample->name,i).c_str(),curSample==i)) {
curSample=i;
samplePos=0;
updateSampleTex=true;
}
if (ImGui::IsItemHovered() && !mobileUI) {
ImGui::PushStyleColor(ImGuiCol_Text,uiColors[GUI_COLOR_TEXT]);
ImGui::SetTooltip("Bank %d: %s",i/12,sampleNote[i%12]);
if (ImGui::IsMouseDoubleClicked(ImGuiMouseButton_Left)) {
sampleEditOpen=true;
nextWindow=GUI_WINDOW_SAMPLE_EDIT;
}
ImGui::PopStyleColor();
}
if (memWarning) {
ImGui::SameLine();
ImGui::Text(ICON_FA_EXCLAMATION_TRIANGLE);
if (ImGui::IsItemHovered() && !mobileUI) {
ImGui::PushStyleColor(ImGuiCol_Text,uiColors[GUI_COLOR_TEXT]);
ImGui::SetTooltip("out of memory for this sample!");
ImGui::PopStyleColor();
}
ImGui::PopStyleColor();
}
if (wantScrollList && curSample==i) ImGui::SetScrollHereY();
sampleListItem(i,-1,-1);
}
}

View File

@ -2272,6 +2272,11 @@ void FurnaceGUI::exportAudio(String path, DivAudioExportModes mode) {
displayExporting=true;
}
void FurnaceGUI::editStr(String* which) {
editString=which;
displayEditString=true;
}
void FurnaceGUI::showWarning(String what, FurnaceGUIWarnings type) {
warnString=what;
warnAction=type;
@ -5053,6 +5058,10 @@ bool FurnaceGUI::loop() {
ImGui::OpenPopup("New Song");
}
if (displayEditString) {
ImGui::OpenPopup("EditString");
}
if (nextWindow==GUI_WINDOW_ABOUT) {
aboutOpen=true;
nextWindow=GUI_WINDOW_NOTHING;
@ -5592,6 +5601,27 @@ bool FurnaceGUI::loop() {
ImGui::EndPopup();
}
if (ImGui::BeginPopup("EditString",ImGuiWindowFlags_AlwaysAutoResize|ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoSavedSettings)) {
if (editString==NULL) {
ImGui::Text("Error! No string provided!");
} else {
if (displayEditString) {
ImGui::SetItemDefaultFocus();
ImGui::SetKeyboardFocusHere();
}
ImGui::InputText("##StringVal",editString);
}
displayEditString=false;
ImGui::SameLine();
if (ImGui::Button("OK") || ImGui::IsKeyPressed(ImGuiKey_Enter,false)) {
editString=NULL;
ImGui::CloseCurrentPopup();
}
ImGui::EndPopup();
} else {
editString=NULL;
}
MEASURE_END(popup);
if (!tutorial.introPlayed || settings.alwaysPlayIntro!=0) {
@ -6452,6 +6482,7 @@ FurnaceGUI::FurnaceGUI():
displayPendingRawSample(false),
snesFilterHex(false),
modTableHex(false),
displayEditString(false),
mobileEdit(false),
vgmExportVersion(0x171),
vgmExportTrailingTicks(-1),
@ -6471,6 +6502,7 @@ FurnaceGUI::FurnaceGUI():
fmPreviewOn(false),
fmPreviewPaused(false),
fmPreviewOPN(NULL),
editString(NULL),
pendingRawSampleDepth(8),
pendingRawSampleChannels(1),
pendingRawSampleUnsigned(false),
@ -6525,7 +6557,6 @@ FurnaceGUI::FurnaceGUI():
loopEnd(-1),
isClipping(0),
extraChannelButtons(0),
patNameTarget(-1),
newSongCategory(0),
latchTarget(0),
wheelX(0),
@ -6596,7 +6627,6 @@ FurnaceGUI::FurnaceGUI():
collapseWindow(false),
demandScrollX(false),
fancyPattern(false),
wantPatName(false),
firstFrame(true),
tempoView(true),
waveHex(false),

View File

@ -1223,7 +1223,7 @@ class FurnaceGUI {
bool portrait, injectBackUp, mobileMenuOpen;
bool wantCaptureKeyboard, oldWantCaptureKeyboard, displayMacroMenu;
bool displayNew, fullScreen, preserveChanPos, wantScrollList, noteInputPoly;
bool displayPendingIns, pendingInsSingle, displayPendingRawSample, snesFilterHex, modTableHex;
bool displayPendingIns, pendingInsSingle, displayPendingRawSample, snesFilterHex, modTableHex, displayEditString;
bool mobileEdit;
bool willExport[DIV_MAX_CHIPS];
int vgmExportVersion;
@ -1241,6 +1241,7 @@ class FurnaceGUI {
short fmPreview[FM_PREVIEW_SIZE];
bool updateFMPreview, fmPreviewOn, fmPreviewPaused;
void* fmPreviewOPN;
String* editString;
String pendingRawSample;
int pendingRawSampleDepth, pendingRawSampleChannels;
@ -1602,7 +1603,7 @@ class FurnaceGUI {
DivInstrument* prevInsData;
int curIns, curWave, curSample, curOctave, curOrder, prevIns, oldRow, oldOrder, oldOrder1, editStep, exportLoops, soloChan,orderEditMode, orderCursor;
int loopOrder, loopRow, loopEnd, isClipping, extraChannelButtons, patNameTarget, newSongCategory, latchTarget;
int loopOrder, loopRow, loopEnd, isClipping, extraChannelButtons, newSongCategory, latchTarget;
int wheelX, wheelY, dragSourceX, dragSourceXFine, dragSourceY, dragDestinationX, dragDestinationXFine, dragDestinationY, oldBeat, oldBar;
int curGroove;
float soloTimeout;
@ -1625,7 +1626,7 @@ class FurnaceGUI {
SelectionPoint selStart, selEnd, cursor, cursorDrag, dragStart, dragEnd;
bool selecting, selectingFull, dragging, curNibble, orderNibble, followOrders, followPattern, changeAllOrders, mobileUI;
bool collapseWindow, demandScrollX, fancyPattern, wantPatName, firstFrame, tempoView, waveHex, waveSigned, waveGenVisible, lockLayout, editOptsVisible, latchNibble, nonLatchNibble;
bool collapseWindow, demandScrollX, fancyPattern, firstFrame, tempoView, waveHex, waveSigned, waveGenVisible, lockLayout, editOptsVisible, latchNibble, nonLatchNibble;
bool keepLoopAlive, keepGrooveAlive, orderScrollLocked, orderScrollTolerance, dragMobileMenu, dragMobileEditButton, wantGrooveListFocus;
FurnaceGUIWindows curWindow, nextWindow, curWindowLast;
std::atomic<FurnaceGUIWindows> curWindowThreadSafe;
@ -2002,7 +2003,7 @@ class FurnaceGUI {
void actualSampleList();
void insListItem(int index, int dir, int asset);
void waveListItem(int index, int dir, int asset);
void waveListItem(int index, float* wavePreview, int dir, int asset);
void sampleListItem(int index, int dir, int asset);
void toggleMobileUI(bool enable, bool force=false);
@ -2165,6 +2166,7 @@ class FurnaceGUI {
const char* getSystemName(DivSystem which);
public:
void editStr(String* which);
void showWarning(String what, FurnaceGUIWarnings type);
void showError(String what);
String getLastError();

View File

@ -834,28 +834,9 @@ void FurnaceGUI::drawPattern() {
if (extraChannelButtons==2) {
DivPattern* pat=e->curPat[i].getPattern(e->curOrders->ord[i][ord],true);
ImGui::PushFont(mainFont);
if (patNameTarget==i) {
snprintf(chanID,2048,"##PatNameI%d_%d",i,ord);
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x-(8.0f*dpiScale));
ImGui::SetCursorPosX(ImGui::GetCursorPosX()+4.0f*dpiScale);
ImGui::InputText(chanID,&pat->name);
if (wantPatName) {
wantPatName=false;
ImGui::SetItemDefaultFocus();
ImGui::SetKeyboardFocusHere(-1);
} else {
if (!ImGui::IsItemActive()) {
patNameTarget=-1;
}
}
} else {
snprintf(chanID,2048," %s##PatName%d",pat->name.c_str(),i);
if (ImGui::Selectable(chanID,true,ImGuiSelectableFlags_NoPadWithHalfSpacing,ImVec2(0.0f,lineHeight+1.0f*dpiScale))) {
patNameTarget=i;
wantPatName=true;
snprintf(chanID,2048,"##PatNameI%d_%d",i,ord);
ImGui::SetActiveID(ImGui::GetID(chanID),ImGui::GetCurrentWindow());
}
snprintf(chanID,2048," %s##PatName%d",pat->name.c_str(),i);
if (ImGui::Selectable(chanID,true,ImGuiSelectableFlags_NoPadWithHalfSpacing,ImVec2(0.0f,lineHeight+1.0f*dpiScale))) {
editStr(&pat->name);
}
ImGui::PopFont();
} else if (extraChannelButtons==1) {