MCPcopy Create free account
hub / github.com/HertzDevil/0CC-FamiTracker / DrawCell

Method DrawCell

Source/PatternEditor.cpp:1259–1449  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1257}
1258
1259void CPatternEditor::DrawCell(CDC &DC, int PosX, cursor_column_t Column, int Channel, bool bInvert,
1260 const stChanNote &NoteData, const RowColorInfo_t &ColorInfo) const // // //
1261{
1262 // Sharps
1263 const wchar_t NOTES_A_SHARP[] = {L'C', L'C', L'D', L'D', L'E', L'F', L'F', L'G', L'G', L'A', L'A', L'B'};
1264 const wchar_t NOTES_B_SHARP[] = {L'-', L'#', L'-', L'#', L'-', L'-', L'#', L'-', L'#', L'-', L'#', L'-'};
1265 // Flats
1266 const wchar_t NOTES_A_FLAT[] = {L'C', L'D', L'D', L'E', L'E', L'F', L'G', L'G', L'A', L'A', L'B', L'B'};
1267 const wchar_t NOTES_B_FLAT[] = {L'-', L'b', L'-', L'b', L'-', L'-', L'b', L'-', L'b', L'-', L'b', L'-'};
1268 // Octaves
1269 const wchar_t NOTES_C[] = {L'0', L'1', L'2', L'3', L'4', L'5', L'6', L'7', L'8', L'9'};
1270 // Hex numbers
1271 const wchar_t HEX[] = {L'0', L'1', L'2', L'3', L'4', L'5', L'6', L'7', L'8', L'9', L'A', L'B', L'C', L'D', L'E', L'F'};
1272
1273 const bool m_bDisplayFlat = FTEnv.GetSettings()->Appearance.bDisplayFlats; // // //
1274
1275 const wchar_t *NOTES_A = m_bDisplayFlat ? NOTES_A_FLAT : NOTES_A_SHARP;
1276 const wchar_t *NOTES_B = m_bDisplayFlat ? NOTES_B_FLAT : NOTES_B_SHARP;
1277
1278 stEffectCommand Eff = Column >= cursor_column_t::EFF1_NUM ? NoteData.Effects[value_cast(GetSelectColumn(Column)) - 3] : stEffectCommand { }; // // //
1279
1280 // Detect invalid note data
1281 if (NoteData.Note > note_t::echo || // // //
1282 NoteData.Octave > 8 ||
1283 enum_cast(Eff.fx) != Eff.fx ||
1284 NoteData.Instrument > MAX_INSTRUMENTS && NoteData.Instrument != HOLD_INSTRUMENT) { // // // 050B
1285 if (Column == cursor_column_t::NOTE /* || Column == cursor_column_t::EFF1_NUM*/) {
1286 CStringW Text = L"(invalid)";
1287 DC.SetTextColor(MakeRGB(255, 0, 0));
1288 DC.TextOutW(PosX, -1, Text);
1289 }
1290 return;
1291 }
1292
1293 COLORREF InstColor = ColorInfo.Instrument;
1294 COLORREF EffColor = ColorInfo.Effect;
1295 COLORREF DimInst = ColorInfo.Compact; // // //
1296 COLORREF DimEff = ColorInfo.Compact; // // //
1297
1298 CSongView *pSongView = m_pView->GetSongView(); // // //
1299 unsigned fxcols = pSongView->GetEffectColumnCount(Channel);
1300 stChannelID ch = pSongView->GetChannelOrder().TranslateChannel(Channel);
1301
1302 // Make non-available instruments red in the pattern editor
1303 const auto *pManager = m_pModule->GetInstrumentManager();
1304 if (NoteData.Instrument < MAX_INSTRUMENTS &&
1305 (!pManager->HasInstrument(NoteData.Instrument) ||
1306 !IsInstrumentCompatible(ch.Chip, pManager->GetInstrumentType(NoteData.Instrument)))) { // // //
1307 DimInst = InstColor = MakeRGB(255, 0, 0);
1308 }
1309
1310 // // // effects too
1311 if (Eff.fx != effect_t::none && !IsEffectCompatible(ch, Eff))
1312 DimEff = EffColor = MakeRGB(255, 0, 0); // // //
1313
1314 int PosY = m_iRowHeight - m_iRowHeight / 8; // // //
1315 // // // PosX -= 1;
1316

Callers

nothing calls this directly

Calls 15

value_castFunction · 0.85
GetSelectColumnFunction · 0.85
enum_castFunction · 0.85
MakeRGBFunction · 0.85
IsInstrumentCompatibleFunction · 0.85
IsEffectCompatibleFunction · 0.85
GradientBarFunction · 0.85
IsAPUNoiseFunction · 0.85
IsDPCMFunction · 0.85
GetSongViewMethod · 0.80
HasInstrumentMethod · 0.80
GetInstrumentTypeMethod · 0.80

Tested by

no test coverage detected