diff --git a/Readme.md b/Readme.md index 0c777af..d0cd4ac 100644 --- a/Readme.md +++ b/Readme.md @@ -880,4 +880,26 @@ Not problems, for the record: forward slashes in CSV paths work fine on Windows, and Windows' case-insensitivity means anything working on Linux also works there — never the reverse. Develop on Linux and Windows -comes free. \ No newline at end of file +comes free. + +## 21. Legacy 7-region Mode + +A new `--legacy` flag enables a legacy mode that supports the older Python application's behavior: + +- **Flag**: Run with `--legacy` to enable the 7-region audio mode +- **Data files**: Uses `cases_old.csv`, `map_old/`, and `sound_old/` directories +- **CSV format**: 28-column format (no header) with positional columns for each region +- **Audio behavior**: Mixes 7 regional sound sources simultaneously instead of single-map mode +- **Controls**: + - Ctrl+R toggles the color overlay + - Audio changes in real-time as you move across the chest + - Meters show volume levels for each of the 7 regions + +The legacy mode preserves all existing functionality while adding the new multi-region audio capabilities. + +The following files are required for the legacy mode: +- `cases_old.csv` (UTF-8, no header, 28 columns) +- `map_old/` directory with MAP###.png files +- `sound_old/` directory with SND###.wav files + +When running without `--legacy`, all existing behavior remains unchanged. diff --git a/program/AppMode.cs b/program/AppMode.cs new file mode 100644 index 0000000..7f2c8a7 --- /dev/null +++ b/program/AppMode.cs @@ -0,0 +1,36 @@ +using System; +using System.IO; + +public static class AppMode +{ + /// false = current single-map mode, true = legacy 7-region mode. + public static bool Legacy = false; + + public static string CasesCsv + { + get { return SoundWindow.AppFile(Legacy ? "cases_old.csv" : "cases.csv"); } + } + + private static string MapDir { get { return Legacy ? "map_old" : "map"; } } + // private static string SoundDir { get { return Legacy ? "sound_old" : "sound"; } } + /// Shared by both modes: legacy and current read from the same folder. + private const string SoundDir = "sound"; + + /// CSV value -> absolute path. Returns null for "none"/empty. + public static string ResolveMap(string csvValue) { return Resolve(csvValue, MapDir, "map"); } + public static string ResolveSound(string csvValue) { return Resolve(csvValue, SoundDir, "sound"); } + + private static string Resolve(string csvValue, string dir, string fallbackDir) + { + if (string.IsNullOrWhiteSpace(csvValue)) return null; + if (csvValue.Trim().Equals("none", StringComparison.OrdinalIgnoreCase)) return null; + + string file = Path.GetFileName(csvValue.Trim()); + string path = SoundWindow.AppFile(Path.Combine(dir, file)); + + if (!File.Exists(path) && Legacy) // shared asset fallback + path = SoundWindow.AppFile(Path.Combine(fallbackDir, file)); + + return path; + } +} \ No newline at end of file diff --git a/program/AudioEngine.cs b/program/AudioEngine.cs index 0815f64..8b763b8 100644 --- a/program/AudioEngine.cs +++ b/program/AudioEngine.cs @@ -3,6 +3,8 @@ using System.IO; using OpenTK.Audio; using OpenTK.Audio.OpenAL; +using System.Runtime.InteropServices; + public class AudioEngine : IDisposable { @@ -37,8 +39,11 @@ } } - /// Load + start looping at gain 0. Idempotent. - public Voice Warm(string wavPath) + /// Load + start looping at gain 0. Idempotent per key. + /// Load + start looping at gain 0. Idempotent per key. + public Voice Warm(string wavPath) { return Warm(wavPath, wavPath); } + + public Voice Warm(string wavPath, string key) { if (string.IsNullOrEmpty(wavPath) || !File.Exists(wavPath)) { @@ -49,7 +54,7 @@ lock (_lock) { Voice v; - if (_voices.TryGetValue(wavPath, out v)) return v; + if (_voices.TryGetValue(key, out v)) return v; // ← key, not wavPath try { @@ -62,13 +67,13 @@ AL.Source(src, ALSourcei.Buffer, buf); AL.Source(src, ALSourceb.Looping, true); AL.Source(src, ALSourcef.Gain, 0.0f); - AL.SourcePlay(src); // runs continuously, silent + AL.SourcePlay(src); CheckError("Warm " + Path.GetFileName(wavPath)); v = new Voice { Path = wavPath, Buffer = buf, Source = src, Gain = 0f }; - _voices[wavPath] = v; - Emit("Warmed " + Path.GetFileName(wavPath)); + _voices[key] = v; // ← key + Emit("Warmed " + Path.GetFileName(wavPath) + " [" + key + "]"); return v; } catch (Exception ex) diff --git a/program/CaseDefinition.cs b/program/CaseDefinition.cs index 39b9c85..d8489be 100644 --- a/program/CaseDefinition.cs +++ b/program/CaseDefinition.cs @@ -4,7 +4,7 @@ using System.IO; using System.Text; -/// One row of cases.csv. +/// One row of cases.csv (or cases_old.csv in legacy mode). public class CaseDefinition { public int Number { get; set; } // Number @@ -21,6 +21,14 @@ public string MapLeft { get; set; } // Image_Left public string MapBack { get; set; } // Image_Back + // ── legacy 7-region fields ──────────────────────────────────────── + public string[] RegionMaps = new string[7]; + public string[] RegionSounds = new string[7]; + public string[] RegionIcons = new string[7]; + public int InhaleStart, ExhaleStart, ExhaleEnd; // fields, so TryParse(out …) compiles + public string ManualFile; + public bool IsLegacy; + public bool IsHeart { get { return !string.IsNullOrEmpty(Type) && Type.Contains("心"); } @@ -44,7 +52,7 @@ return Number + ": " + string.Join(" : ", TreePath); } - // ── loader ───────────────────────────────────────────────────────── + // ── loader: current mode (cases.csv) ────────────────────────────── public static List LoadCasesFromCsv(string path) { @@ -79,7 +87,6 @@ char sep = lines[0].Contains("\t") ? '\t' : ','; // Header name -> column index, so adding or reordering columns is safe. - // string[] header = lines[0].TrimStart('\uFEFF').Split(sep); string[] header = lines[0].TrimStart(new[] { '\uFEFF' }).Split(sep); var idx = new Dictionary(StringComparer.OrdinalIgnoreCase); for (int i = 0; i < header.Length; i++) @@ -140,4 +147,70 @@ (skipped > 0 ? " (" + skipped + " skipped)" : "")); return list; } + + // ── loader: legacy mode (cases_old.csv) ─────────────────────────── + + /// Reads the Python-format case.csv: no header, 28 positional columns. + public static List LoadLegacyCasesFromCsv(string path) + { + var list = new List(); + if (!File.Exists(path)) + { + Console.WriteLine("Legacy CSV not found: " + path); + return list; + } + + string[] lines; + try { lines = File.ReadAllLines(path, Encoding.UTF8); } + catch (Exception ex) + { + Console.WriteLine("Failed to read " + path + ": " + ex.Message); + return list; + } + + int n = 0; + foreach (string raw in lines) + { + if (string.IsNullOrWhiteSpace(raw)) continue; + + string line = raw.TrimStart('\uFEFF'); + string[] f = line.Split(line.Contains("\t") ? '\t' : ','); + + if (f.Length < 28) + { + Console.WriteLine("Legacy row skipped: expected 28 fields, got " + f.Length); + continue; + } + + n++; + var d = new CaseDefinition + { + IsLegacy = true, + Number = 900 + n, // no clash with cases.csv, below MULTICOLOR_THRESHOLD + TreeLevel1 = f[0].Trim() + }; + + for (int k = 0; k < 7; k++) + { + d.RegionMaps[k] = f[1 + k * 3].Trim(); + d.RegionSounds[k] = f[2 + k * 3].Trim(); + d.RegionIcons[k] = f[3 + k * 3].Trim(); + } + + int flag; + int.TryParse(f[23].Trim(), out flag); + d.Type = (flag == 1) ? "心音" : "呼吸音"; // drives IsHeart and the tree root + + int.TryParse(f[24].Trim(), out d.InhaleStart); + int.TryParse(f[25].Trim(), out d.ExhaleStart); + int.TryParse(f[26].Trim(), out d.ExhaleEnd); + d.ManualFile = f[27].Trim(); + + d.MapFront = d.RegionMaps[0]; // so display code has a fallback + list.Add(d); + } + + Console.WriteLine("Loaded " + list.Count + " legacy cases from " + path); + return list; + } } \ No newline at end of file diff --git a/program/LEGACY_MODE_FIX.md b/program/LEGACY_MODE_FIX.md new file mode 100644 index 0000000..1ba99e2 --- /dev/null +++ b/program/LEGACY_MODE_FIX.md @@ -0,0 +1,156 @@ +# Fix: `--legacy` flag is not reaching the case loader + +## Symptom + +``` +argv = [.../program.exe | --legacy | --debug] +Loaded 98 cases from .../bin/linux/cases.csv +``` + +`cases.csv` has 98 rows — that is the **current-mode** loader running. The legacy +loader prints `Loaded N legacy cases from …`, so `LoadLegacyCasesFromCsv` never ran. +The map looks unchanged for the same reason: the app is in normal mode end to end. + +So this is not a map-drawing bug. Fix the flag first, then re-check the map. + +## Likely causes, in order + +1. `Program.cs` sets `AppMode.Legacy` **after** the widgets are built, so + `SoundWindow`'s constructor already ran with `Legacy == false`. +2. `Program.cs` step was never applied — `argv` is printed by pre-existing arg-parsing + code, which proves an arg parser exists but not that ours was added to it. +3. `SoundWindow` still calls `CaseDefinition.LoadCasesFromCsv(AppFile("cases.csv"))` + instead of the `AppMode` version. +4. Assets aren't next to the exe. Note the working dir is `program/` but files resolve + to `program/bin/linux/` — `cases_old.csv`, `map_old/`, `sound_old/` must be in + **`bin/linux/`**, not the repo root. + +## Step 1 — diagnose before editing + +Report back, don't fix yet: + +- Paste the full `Program.cs` `Main`, in order, from the first line to + `Application.Run()`. Mark exactly where `AppMode.Legacy` is assigned, or state that it + is absent. +- Paste the current `SoundWindow` constructor lines that load `_allCases`. +- Run `ls -la bin/linux/` and report whether `cases_old.csv`, `map_old/`, `sound_old/` + exist there. +- Confirm whether `AppMode.cs` and `RegionSound.cs` are in the build command actually + used to produce `bin/linux/program.exe` (check the Makefile / build script, not just + the files on disk). + +## Step 2 — make the flag observable + +Add these three log lines so the mode is never ambiguous again. + +In `Program.cs`, immediately after the `AppMode.Legacy` assignment: + +```csharp +Console.WriteLine("AppMode.Legacy = " + AppMode.Legacy + + " cases=" + AppMode.CasesCsv); +``` + +In the `SoundWindow` constructor, as the first line: + +```csharp +Console.WriteLine("SoundWindow ctor: AppMode.Legacy = " + AppMode.Legacy); +``` + +In `MapWindow.ShowCase`, after `_case` is assigned: + +```csharp +Logger.Write("map", "ShowCase legacy=" + AppMode.Legacy + + " regions=" + _regions.Count); +``` + +## Step 3 — set the flag before anything reads it + +`AppMode.Legacy` must be assigned **before** `Application.Init()` and before any +`Builder` / window / `SoundWindow` construction. If the existing parser handles +`--debug`, add `--legacy` to that same parser and move the whole parse block to the top +of `Main`, above `Application.Init()`. Do not add a second parser. + +Target shape: + +```csharp +static void Main(string[] args) +{ + Console.WriteLine("argv = [" + string.Join(" | ", args) + "]"); + + // --- flags first, before any UI construction --- + AppMode.Legacy = Array.IndexOf(args, "--legacy") >= 0; + // ... existing --debug handling stays here too ... + Console.WriteLine("AppMode.Legacy = " + AppMode.Legacy + + " cases=" + AppMode.CasesCsv); + + Application.Init(); + // ... existing window construction ... + Application.Run(); +} +``` + +If `Main` already lives in a different file or class than expected, edit that one — find +it by searching for the `argv = [` line that appears in the log. + +## Step 4 — verify `SoundWindow` uses `AppMode` + +The constructor must read: + +```csharp +_allCases = AppMode.Legacy + ? CaseDefinition.LoadLegacyCasesFromCsv(AppMode.CasesCsv) + : CaseDefinition.LoadCasesFromCsv(AppMode.CasesCsv); +``` + +If a literal `"cases.csv"` string remains anywhere in `SoundWindow`, replace it. +Then grep the whole repo for `"cases.csv"` and report every remaining hit — another +class may be loading the CSV independently. + +## Step 5 — assets in the right folder + +`SoundWindow.AppFile` resolves next to the assembly, which is `bin/linux/`. If the build +copies `cases.csv`, `map/`, and `sound/` there, make it copy `cases_old.csv`, +`map_old/`, and `sound_old/` the same way. Update the Makefile / build script rather +than copying by hand, and say which file you changed. + +## Step 6 — re-verify, then look at the map + +Run: + +```bash +mono ./bin/linux/program.exe --legacy --debug +``` + +Expected, in this order: + +``` +AppMode.Legacy = True cases=.../bin/linux/cases_old.csv +SoundWindow ctor: AppMode.Legacy = True +Loaded 28 legacy cases from .../bin/linux/cases_old.csv +``` + +Only once you see `Loaded 28 legacy cases`, select a case and check the log for: + +``` +[map] region 心音1: MAP100.png + SND100.wav +[map] ... +[map] N/7 regions active +[map] ShowCase legacy=True regions=N +``` + +Report which of these appear. Then, and only then, we debug the drawing: + +- `regions=0` → the region files aren't resolving; paste the `region … map missing` + lines. +- `regions>0` but the map looks identical → the `ShowCase` branch from Step 9 of the + original task wasn't applied, or `_map` is being overwritten after it by a later + `LoadMap(MapPathForView())` call. Paste the whole `ShowCase` method. +- Colours appear but no bars → `DrawRegionMeters` isn't being called from `OnMapDrawn`. + +## Rules + +- Steps 1 and 6 are report-only. Do not edit files during them. +- Do not "fix" this by defaulting `AppMode.Legacy` to `true`, by hardcoding + `cases_old.csv`, or by calling the legacy loader unconditionally. +- Do not touch the map-drawing code until the log proves the legacy loader ran. +- One step per change set, with a diff, and wait for approval. \ No newline at end of file diff --git a/program/MainWindow.cs b/program/MainWindow.cs index bdd42c2..7490331 100644 --- a/program/MainWindow.cs +++ b/program/MainWindow.cs @@ -62,6 +62,20 @@ private BatteryStatus _battery = new BatteryStatus(); private uint _batteryTimerId; private const uint BatteryPollMs = 10000; + + private readonly List _regions = new List(); + + private static readonly string[] RegionLabels = { + "心音1","心音2","気管","気管支","気管支肺胞","右肺胞","左肺胞" }; + + // RGB triples — no System.Drawing dependency. + private static readonly byte[][] RegionColors = { + new byte[]{220, 60, 60}, new byte[]{255,140, 0}, + new byte[]{ 60,160,230}, new byte[]{ 40,100,210}, + new byte[]{ 90,190,140}, new byte[]{180,120,220}, + new byte[]{230,200, 70} }; + + private bool _showRegions = true; // Ctrl+R toggles public MainWindow() : this(CreateBuilder()) { } diff --git a/program/MapWindow.cs b/program/MapWindow.cs index d742f3f..4906fab 100644 --- a/program/MapWindow.cs +++ b/program/MapWindow.cs @@ -126,6 +126,21 @@ public bool HeartSoundEnabled = false; public bool BreathSoundEnabled = false; + private readonly List _regions = new List(); + private bool _showRegions = true; // Ctrl+R toggles the colour overlay + private bool _showRegionLabels = true; + private CheckButton _hideLabelsCheck; + + private static readonly string[] RegionLabels = { + "心音1","心音2","気管","気管支","気管支肺胞","右肺胞","左肺胞" }; + + // RGB triples — byte arrays, to avoid a System.Drawing dependency. + private static readonly byte[][] RegionColors = { + new byte[]{220, 60, 60}, new byte[]{255,140, 0}, + new byte[]{ 60,160,230}, new byte[]{ 40,100,210}, + new byte[]{ 90,190,140}, new byte[]{180,120,220}, + new byte[]{230,200, 70} }; + private int _lastPx = -1, _lastPy = -1; private const int TAG_IDLE_MS = 250; // Form2's noDataIntervalMs private const int WATCHDOG_MS = 100; @@ -327,6 +342,11 @@ if ((a.Event.State & Gdk.ModifierType.ControlMask) == 0) return; if (a.Event.Key == Gdk.Key.t || a.Event.Key == Gdk.Key.T) ToggleTuner(); + else if (a.Event.Key == Gdk.Key.r || a.Event.Key == Gdk.Key.R) + { + _showRegions = !_showRegions; + MapArea.QueueDraw(); + } }; } @@ -352,7 +372,21 @@ _highlighted.Clear(); Logger.Write("chip", "raw='" + line + "' fullMatches=" + fullMatches.Count + // NEW - " avgMatch=" + avgMatch.Success); + " avgMatch=" + avgMatch.Success); + + if (AppMode.Legacy) + { + // For legacy mode, we need to process the position first before applying audio + double bx, by; + if (!_hasPosition || !TryGetCursorBodyPoint(out bx, out by)) + { + MuteRegions(); + return; + } + + if (_case != null) ApplyRegionAudio(bx, by); + return; // skip the single-voice path entirely + } if (avgMatch.Success) { @@ -603,22 +637,40 @@ DisposePixbufs(); _body = LoadBody(); - // _map = LoadMap(MapPathForView()); - _map = LoadMap(MapPathForView(), MapNeedsMirror()); + + if (AppMode.Legacy) + { + LoadRegions(def); + var overlay = BuildRegionOverlay(MapSize, MapSize); + _mapRaw = overlay != null ? overlay.Copy() : null; + _map = overlay; + _mapPath = "(7 regions composite)"; + } + else + { + // _map = LoadMap(MapPathForView()); + _map = LoadMap(MapPathForView(), MapNeedsMirror()); + } MapArea.QueueDraw(); UpdateTunerInfo(); - _caseVoice = _sound.Warm(SoundWindow.AppFile(def.SoundPath)); - - if (HeartSoundEnabled) + + if (!AppMode.Legacy) { - _heart1 = _sound.Warm(SoundWindow.AppFile("sound/SND100.wav")); - _heart2 = _sound.Warm(SoundWindow.AppFile("sound/SND101.wav")); - } - if (BreathSoundEnabled) - _breath = _sound.Warm(SoundWindow.AppFile("sound/SND200.wav")); + _caseVoice = _sound.Warm(SoundWindow.AppFile(def.SoundPath)); - _sound.MuteAll(); // everything loops silently until a tag lands + if (HeartSoundEnabled) + { + _heart1 = _sound.Warm(AppMode.ResolveSound("SND100.wav")); + _heart2 = _sound.Warm(AppMode.ResolveSound("SND101.wav")); + } + if (BreathSoundEnabled) + _breath = _sound.Warm(AppMode.ResolveSound("SND200.wav")); + + + _sound.MuteAll(); // everything loops silently until a tag lands + } + LoadWaveforms(def); _playClock.Restart(); // voices were just warmed -> loop position 0 StartWaveTimer(); @@ -631,6 +683,7 @@ public void StopSession() { StopDebugSweep(); + MuteRegions(); // NEW: stop legacy audio too // _sound.Stop(); _sound.MuteAll(); // keep voices warm — re-entry is instant StopWaveTimer(); @@ -732,7 +785,9 @@ cr.Translate(mx, my); cr.Scale(sx, sy); Gdk.CairoHelper.SetSourcePixbuf(cr, src, 0, 0); - cr.PaintWithAlpha(T.MapAlpha); + // Guard the existing map-overlay draw with (!AppMode.Legacy || _showRegions) + if (!AppMode.Legacy || _showRegions) + cr.PaintWithAlpha(T.MapAlpha); cr.Restore(); } @@ -769,6 +824,10 @@ if (_hasPosition) DrawCoordHud(cr, w, h); //show the coordinate on top of the image + // At the very end, before args.RetVal = true, add: + if (AppMode.Legacy && _regions.Count > 0) + DrawRegionMeters(cr); + args.RetVal = true; } @@ -1336,6 +1395,18 @@ // _map = LoadMap(MapPathForView()); _map = LoadMap(MapPathForView(), MapNeedsMirror()); + if (AppMode.Legacy) + { + RebuildLegacyMap(); + UpdateTunerInfo(); + MapArea.QueueDraw(); + Logger.Write("view", "-> " + view + " (legacy)"); + return; + } + if (_map != null) { _map.Dispose(); _map = null; } + if (_mapRaw != null) { _mapRaw.Dispose(); _mapRaw = null; } + _map = LoadMap(MapPathForView(), MapNeedsMirror()); + SyncSpins(); UpdateTunerInfo(); MapArea.QueueDraw(); @@ -1344,8 +1415,14 @@ private void ReloadBody() { - if (_body != null) { _body.Dispose(); _body = null; } - _body = LoadBody(); + if (AppMode.Legacy) + RebuildLegacyMap(); + else + { + if (_map != null) { _map.Dispose(); _map = null; } + if (_mapRaw != null) { _mapRaw.Dispose(); _mapRaw = null; } + _map = LoadMap(MapPathForView(), MapNeedsMirror()); + } UpdateTunerInfo(); MapArea.QueueDraw(); } @@ -1498,6 +1575,11 @@ _arduino.LineReceived -= OnArduinoLine; _arduino.ConnectionChanged -= OnArduinoConnectionChanged; if (_watchdogId != 0) { GLib.Source.Remove(_watchdogId); _watchdogId = 0; } + + // NEW: cleanup legacy regions + foreach (var r in _regions) r.Dispose(); + _regions.Clear(); + _sound.Dispose(); DisposePixbufs(); if (_tuner != null) { _tuner.Destroy(); _tuner = null; } @@ -1630,19 +1712,29 @@ { _heartCursor = _breathCursor = -1; - WaveData caseWave = LoadWave(def.SoundPath); + // Legacy has no SoundPath; show the first active region's sound instead + string caseSound = def.SoundPath; + if (def.IsLegacy) + { + caseSound = null; + for (int k = 0; k < 7 && caseSound == null; k++) + if (AppMode.ResolveSound(def.RegionSounds[k]) != null) + caseSound = def.RegionSounds[k]; + } + + WaveData caseWave = LoadWave(caseSound); if (def.IsHeart) { _heartWave = caseWave; - _breathWave = LoadWave("sound/SND200.wav"); // default breath sound + _breathWave = LoadWave("SND200.wav"); // default breath sound _heartLive = true; - _breathLive = BreathSoundEnabled; // only "playing" if that voice was warmed + _breathLive = BreathSoundEnabled; } else { _breathWave = caseWave; - _heartWave = LoadWave("sound/SND100.wav"); // default heart sound + _heartWave = LoadWave("SND100.wav"); // default heart sound _breathLive = true; _heartLive = HeartSoundEnabled; } @@ -1651,16 +1743,58 @@ BreathWaveArea.QueueDraw(); } - private static WaveData LoadWave(string rel) + private static WaveData LoadWave(string csvValue) { + string full = AppMode.ResolveSound(csvValue); // null-safe, uses shared sound/ folder + if (full == null) + { + Logger.Write("wave", "no sound for waveform (" + (csvValue ?? "null") + ")"); + return null; // draw code already shows a flat line + } + string err; - WaveData w = WaveData.Load(SoundWindow.AppFile(rel), out err); - if (w == null) Logger.Write("wave", "load failed " + rel + ": " + err); - else Logger.Write("wave", "loaded " + rel + " (" + - w.Duration.ToString("F2", CultureInfo.InvariantCulture) + " s)"); + WaveData w = WaveData.Load(full, out err); + if (w == null) Logger.Write("wave", "load failed " + full + ": " + err); + else Logger.Write("wave", "loaded " + full + " (" + + w.Duration.ToString("F2", CultureInfo.InvariantCulture) + " s)"); return w; } + // private void LoadWaveforms(CaseDefinition def) + // { + // _heartCursor = _breathCursor = -1; + + // WaveData caseWave = LoadWave(def.SoundPath); + + // if (def.IsHeart) + // { + // _heartWave = caseWave; + // _breathWave = LoadWave("sound/SND200.wav"); // default breath sound + // _heartLive = true; + // _breathLive = BreathSoundEnabled; // only "playing" if that voice was warmed + // } + // else + // { + // _breathWave = caseWave; + // _heartWave = LoadWave("sound/SND100.wav"); // default heart sound + // _breathLive = true; + // _heartLive = HeartSoundEnabled; + // } + + // HeartWaveArea.QueueDraw(); + // BreathWaveArea.QueueDraw(); + // } + + // private static WaveData LoadWave(string rel) + // { + // string err; + // WaveData w = WaveData.Load(SoundWindow.AppFile(rel), out err); + // if (w == null) Logger.Write("wave", "load failed " + rel + ": " + err); + // else Logger.Write("wave", "loaded " + rel + " (" + + // w.Duration.ToString("F2", CultureInfo.InvariantCulture) + " s)"); + // return w; + // } + private void StartWaveTimer() { if (_waveTimerId != 0) return; @@ -1731,4 +1865,268 @@ { get { return (_mapFit == MapFit.FitBody && _mapRaw != null) ? _mapRaw : _map; } } + + /// Body-pixel point -> 0..1 position inside the drawn map rect. + public bool BodyToMapUV(double bx, double by, out double u, out double v) + { + u = v = 0; + double mx, my, mw, mh; + if (!MapRect(out mx, out my, out mw, out mh)) return false; + if (mw <= 0 || mh <= 0) return false; + + u = (bx - mx) / mw; + v = (by - my) / mh; + return (u >= 0 && u < 1 && v >= 0 && v < 1); + } + + private void LoadRegions(CaseDefinition def) + { + _sound.MuteAll(); + foreach (var r in _regions) r.Dispose(); + _regions.Clear(); + + for (int k = 0; k < 7; k++) + { + string mapPath = AppMode.ResolveMap(def.RegionMaps[k]); + string sndPath = AppMode.ResolveSound(def.RegionSounds[k]); + if (mapPath == null || sndPath == null) continue; // region disabled + + var pb = Load(mapPath); // existing helper + if (pb == null) + { + Logger.Write("map", "region " + RegionLabels[k] + " map missing: " + mapPath); + continue; + } + + var voice = _sound.Warm(sndPath, "R" + k + ":" + sndPath); + if (voice == null) { pb.Dispose(); continue; } + _sound.SetGain(voice, 0f); + + var rs = new RegionSound + { + Index = k, Name = RegionLabels[k], + Map = pb, Voice = voice + }; + rs.CachePixels(); + _regions.Add(rs); + + Logger.Write("map", "region " + RegionLabels[k] + ": " + + Path.GetFileName(mapPath) + " + " + Path.GetFileName(sndPath)); + } + + Logger.Write("map", _regions.Count + "/7 regions active"); + } + + /// Call with the same body-pixel coords the single-map path uses. + private void ApplyRegionAudio(double bx, double by) + { + double u, v; + if (!BodyToMapUV(bx, by, out u, out v)) { MuteRegions(); return; } + if (_view == "back") u = 1.0 - u; // mirrored front map + + foreach (var r in _regions) r.Volume = r.VolumeAt(u, v); + + // Heart conflict: only the louder of the two heart modules plays. + RegionSound h1 = _regions.Find(r => r.Index == 0); + RegionSound h2 = _regions.Find(r => r.Index == 1); + if (h1 != null && h2 != null) + { + if (h1.Volume >= h2.Volume) h2.Volume = 0f; + else h1.Volume = 0f; + } + + foreach (var r in _regions) _sound.SetGain(r.Voice, r.Volume); + MapArea.QueueDraw(); // repaint the meters + } + + private void MuteRegions() + { + foreach (var r in _regions) { r.Volume = 0f; _sound.SetGain(r.Voice, 0f); } + MapArea.QueueDraw(); + } + + /// Brightest region wins each pixel; alpha tracks intensity. + private Gdk.Pixbuf BuildRegionOverlay(int w, int h, bool mirror = false) + { + if (_regions.Count == 0) return null; + + int stride = w * 4; + var px = new byte[stride * h]; + var best = new byte[w * h]; + + foreach (var r in _regions) + { + byte[] c = RegionColors[r.Index]; + + for (int y = 0; y < h; y++) + { + double v = (y + 0.5) / h; + for (int x = 0; x < w; x++) + { + double u = (x + 0.5) / w; + if (mirror) u = 1.0 - u; + int val = r.IntensityAt(u, v); + if (val < 12) continue; + + int k = y * w + x; + if (val <= best[k]) continue; + best[k] = (byte)val; + + int o = y * stride + x * 4; + px[o] = c[0]; + px[o + 1] = c[1]; + px[o + 2] = c[2]; + px[o + 3] = (byte)(val * 0.55); + } + } + } + + return new Gdk.Pixbuf(px, Gdk.Colorspace.Rgb, true, 8, w, h, stride); + } + + private void DrawRegionMeters(Cairo.Context cr) + { + if (!_showRegionLabels) return; + + const double rowH = 30, barX = 140, barW = 170, barH = 14, pad = 12; + double y0 = pad; + + cr.Save(); + cr.NewPath(); + cr.SetSourceRGBA(0, 0, 0, 0.72); + cr.Rectangle(pad - 6, y0 - 6, barX + barW + 12, 7 * rowH + 12); + cr.Fill(); + + var layout = Pango.CairoHelper.CreateLayout(cr); + layout.FontDescription = Pango.FontDescription.FromString("Noto Sans CJK JP Bold 15"); + + for (int k = 0; k < 7; k++) + { + RegionSound r = _regions.Find(rs => rs.Index == k); + bool active = r != null && r.Enabled; + double vol = active ? r.Volume : 0.0; + double y = y0 + k * rowH; + + // label + layout.SetText(RegionLabels[k]); + int lw, lh; + layout.GetPixelSize(out lw, out lh); + if (active) cr.SetSourceRGB(1, 1, 1); + else cr.SetSourceRGB(0.55, 0.55, 0.55); + cr.MoveTo(pad, y + (rowH - lh) / 2.0); + Pango.CairoHelper.ShowLayout(cr, layout); + cr.NewPath(); + + // bar background + double by = y + (rowH - barH) / 2.0; + cr.SetSourceRGB(0.30, 0.30, 0.30); + cr.Rectangle(barX, by, barW, barH); + cr.Fill(); + + // bar fill + if (active) + { + byte[] c = RegionColors[k]; + cr.SetSourceRGB(c[0] / 255.0, c[1] / 255.0, c[2] / 255.0); + cr.Rectangle(barX, by, barW * vol, barH); + cr.Fill(); + } + } + + layout.Dispose(); + cr.Restore(); + } + + // private void DrawRegionMeters(Cairo.Context cr) + // { + // const double rowH = 18, barX = 92, barW = 120, pad = 10; + // double y0 = pad; + + // cr.Save(); + // cr.SetSourceRGBA(1, 1, 1, 0.82); + // cr.Rectangle(pad - 4, y0 - 4, barX + barW + 8, 7 * rowH + 8); + // cr.Fill(); + + // cr.SelectFontFace("Sans", Cairo.FontSlant.Normal, Cairo.FontWeight.Normal); + // cr.SetFontSize(11); + + // for (int k = 0; k < 7; k++) + // { + // RegionSound r = _regions.Find(rs => rs.Index == k); + // double vol = (r != null && r.Enabled) ? r.Volume : 0.0; + // double y = y0 + k * rowH; + + // cr.SetSourceRGB(0.15, 0.15, 0.15); + // cr.MoveTo(pad, y + rowH - 5); + // cr.ShowText(RegionLabels[k]); + // cr.NewPath(); + + // cr.SetSourceRGB(0.86, 0.86, 0.86); + // cr.Rectangle(barX, y + 3, barW, 11); + // cr.Fill(); + + // if (r != null) + // { + // byte[] c = RegionColors[k]; + // cr.SetSourceRGB(c[0] / 255.0, c[1] / 255.0, c[2] / 255.0); + // cr.Rectangle(barX, y + 3, barW * vol, 11); + // cr.Fill(); + // } + // else + // { + // cr.SetSourceRGB(0.6, 0.6, 0.6); + // cr.MoveTo(barX, y + 8.5); cr.LineTo(barX + barW, y + 8.5); + // cr.LineWidth = 1; cr.Stroke(); + // } + // } + // cr.Restore(); + // } + + /// Legacy: rebuild the 7-region composite for the current view. + /// Back = mirrored front (same as Form2's CreateFlippedImage fallback). + private void RebuildLegacyMap() + { + if (_map != null) { _map.Dispose(); _map = null; } + if (_mapRaw != null) { _mapRaw.Dispose(); _mapRaw = null; } + + bool mirrored = _view == "back"; + bool shown = _view == "front" || mirrored; + + if (shown) + { + var overlay = BuildRegionOverlay(MapSize, MapSize, mirrored); + _mapRaw = overlay != null ? overlay.Copy() : null; + _map = overlay; + _mapPath = mirrored ? "(7 regions, mirrored)" : "(7 regions composite)"; + } + else _mapPath = "(no legacy map for " + _view + ")"; + + foreach (var r in _regions) r.Enabled = shown; + if (!shown) MuteRegions(); + } + + private void AddHideLabelsOption() + { + if (_hideLabelsCheck != null || HideMapCheck == null) return; + + _hideLabelsCheck = new CheckButton(_lang != null && _lang.IsEnglish ? "Hide labels" : "ラベルを隠す"); + _hideLabelsCheck.StyleContext.AddClass("mappage"); + _hideLabelsCheck.Toggled += (s, e) => + { + _showRegionLabels = !_hideLabelsCheck.Active; + MapArea.QueueDraw(); + }; + + var box = HideMapCheck.Parent as Box; + if (box != null) + { + box.PackStart(_hideLabelsCheck, false, false, 0); + box.ReorderChild(_hideLabelsCheck, Array.IndexOf(box.Children, HideMapCheck) + 1); + } + else if (HideMapCheck.Parent is Container) + ((Container)HideMapCheck.Parent).Add(_hideLabelsCheck); + + _hideLabelsCheck.Show(); + } + } \ No newline at end of file diff --git a/program/RegionSound.cs b/program/RegionSound.cs new file mode 100644 index 0000000..519ccb2 --- /dev/null +++ b/program/RegionSound.cs @@ -0,0 +1,61 @@ +using System; +using System.Runtime.InteropServices; + +public class RegionSound : IDisposable +{ + public int Index; // 0,1 = heart; 2..6 = breath + public string Name; + public Gdk.Pixbuf Map; // raw, NOT black-keyed — audio reference + public AudioEngine.Voice Voice; // owned by AudioEngine's cache + public float Volume; + public bool Enabled = true; + + private byte[] _px; + private int _w, _h, _stride, _ch; + + public bool IsHeart { get { return Index <= 1; } } + + public void CachePixels() + { + if (Map == null) return; + _w = Map.Width; _h = Map.Height; + _stride = Map.Rowstride; _ch = Map.NChannels; + + int len = _stride * (_h - 1) + _w * _ch; // last row is short — don't overrun + _px = new byte[len]; + Marshal.Copy(Map.Pixels, _px, 0, len); + } + + /// u,v are 0..1 across the map, from MapWindow.BodyToMapUV. + public int IntensityAt(double u, double v) + { + if (_px == null) return 0; + int x = (int)(u * _w), y = (int)(v * _h); + if (x < 0 || y < 0 || x >= _w || y >= _h) return 0; + + int i = y * _stride + x * _ch; + if (i + 2 >= _px.Length) return 0; + + byte r = _px[i], b = _px[i + 2]; + return r != 0 ? r : b; // Python: R if R != 0 else B + } + + /// Python EarsSound.volume_change: non-linear curve, breath halved. + public float VolumeAt(double u, double v) + { + if (!Enabled) return 0f; + int val = IntensityAt(u, v); + if (val == 0) return 0f; + + float vol = (float)Math.Pow(val / 255.0, 1.0 / 9.5); + if (!IsHeart) vol *= 0.5f; + return Math.Max(0f, Math.Min(1f, vol)); + } + + public void Dispose() + { + if (Map != null) { Map.Dispose(); Map = null; } + _px = null; + Voice = null; // engine keeps and reuses it + } +} \ No newline at end of file diff --git a/program/SoundWindow.cs b/program/SoundWindow.cs index a8162be..0a0ce7f 100644 --- a/program/SoundWindow.cs +++ b/program/SoundWindow.cs @@ -39,9 +39,13 @@ SoundButtonGrid.Name = "SoundButtonGrid"; SoundBackButton.Name = "SoundBackButton"; - _allCases = CaseDefinition.LoadCasesFromCsv(AppFile("cases.csv")); +Console.WriteLine("SoundWindow ctor: AppMode.Legacy = " + AppMode.Legacy); + _allCases = AppMode.Legacy + ? CaseDefinition.LoadLegacyCasesFromCsv(AppMode.CasesCsv) + : CaseDefinition.LoadCasesFromCsv(AppMode.CasesCsv); + if (_allCases.Count == 0) - Console.WriteLine("WARNING: no cases loaded — check cases.csv"); + Console.WriteLine("WARNING: no cases loaded — check " + AppMode.CasesCsv); SoundBackButton.Clicked += OnBackClicked; } @@ -160,7 +164,24 @@ private void Play(CaseDefinition c) { - if (string.IsNullOrWhiteSpace(c.SoundPath)) + if (c.IsLegacy) + { + // Legacy audio lives in RegionSounds[0..6], not SoundPath + int found = 0; + for (int k = 0; k < 7; k++) + { + string p = AppMode.ResolveSound(c.RegionSounds[k]); + if (p == null) continue; // "none" / empty = region disabled + if (File.Exists(p)) found++; + else Console.WriteLine("Region " + k + " sound missing for case " + c.Number + ": " + p); + } + if (found == 0) + { + Console.WriteLine("No region sounds found for legacy case " + c.Number); + return; + } + } + else if (string.IsNullOrWhiteSpace(c.SoundPath)) { Console.WriteLine("No Sound_File for case " + c.Number); return; @@ -171,17 +192,54 @@ var h = CaseSelected; if (h != null) h(this, c); - // string full = AppFile(c.SoundPath); // "sound/SND200.wav" -> absolute - // if (!File.Exists(full)) - // { - // Console.WriteLine("Sound file missing: " + full); - // return; - // } - - // ConditionNameLabel.Text = string.Join(" : ", _path); - // WavePlayer.Play(full); + if (!c.IsLegacy) + { + string full = AppMode.ResolveSound(c.SoundPath); + if (full == null || !File.Exists(full)) + Console.WriteLine("Sound file missing for case " + c.Number); + } } + // private void Play(CaseDefinition c) + // { + // if (!AppMode.Legacy && string.IsNullOrWhiteSpace(c.SoundPath)) + // { + // Console.WriteLine("No Sound_File for case " + c.Number); + // return; + // } + + // WavePlayer.Stop(); // the map page owns audio from here on + + // var h = CaseSelected; + // if (h != null) h(this, c); + // // if (string.IsNullOrWhiteSpace(c.SoundPath)) + // // { + // // Console.WriteLine("No Sound_File for case " + c.Number); + // // return; + // // } + + // // WavePlayer.Stop(); // the map page owns audio from here on + + // // var h = CaseSelected; + // // if (h != null) h(this, c); + // // string full = AppMode.ResolveSound(c.SoundPath); + // // if (full == null || !File.Exists(full)) + // // { + // // Console.WriteLine("Sound file missing for case " + c.Number); + // // return; + // // } + + // // string full = AppFile(c.SoundPath); // "sound/SND200.wav" -> absolute + // // if (!File.Exists(full)) + // // { + // // Console.WriteLine("Sound file missing: " + full); + // // return; + // // } + + // // ConditionNameLabel.Text = string.Join(" : ", _path); + // // WavePlayer.Play(full); + // } + private void OnBackClicked(object sender, EventArgs e) { if (_path.Count > 0) diff --git a/program/cases_old.csv b/program/cases_old.csv new file mode 100644 index 0000000..f3f1737 --- /dev/null +++ b/program/cases_old.csv @@ -0,0 +1,28 @@ +正常呼吸音,MAP100.png,SND100.wav,heart.png,MAP101.png,SND101.wav,heart.png,MAP200.png,SND200.wav,IMG200.png,MAP201.png,SND201.wav,IMG201.png,MAP202.png,SND202.wav,IMG202.png,MAP203.png,SND203.wav,IMG203.png,MAP203.png,SND203.wav,IMG203.png,2797,0,3000,14500,31000,C999.png +fine crackle(捻髪音),MAP100.png,SND100.wav,heart.png,MAP101.png,SND101.wav,heart.png,MAP200.png,SND300.wav,IMG200.png,MAP208.png,SND301.wav,IMG301.png,MAP202.png,SND202.wav,IMG202.png,MAP210.png,SND210.wav,IMG210.png,MAP210.png,SND210.wav,IMG210.png,2171,0,300,12000,21000,C204.png +coarse crackle(水泡音),MAP100.png,SND100.wav,heart.png,MAP101.png,SND101.wav,heart.png,MAP200.png,SND305.wav,IMG200.png,MAP208.png,SND306.wav,IMG306.png,MAP202.png,SND202.wav,IMG202.png,MAP210.png,SND220.wav,IMG220.png,MAP210.png,SND220.wav,IMG220.png,3545,0,500,17800,31300,C205.png +rhonchi(いびき音),MAP100.png,SND100.wav,heart.png,MAP101.png,SND101.wav,heart.png,MAP200.png,SND310.wav,IMG310.png,MAP208.png,SND311.wav,IMG311.png,MAP202.png,SND202.wav,IMG202.png,MAP210.png,SND230.wav,IMG230.png,MAP210.png,SND230.wav,IMG230.png,4110,0,4000,18000,41000,C206.png +wheeze(笛音),MAP100.png,SND100.wav,heart.png,MAP101.png,SND101.wav,heart.png,MAP200.png,SND315.wav,IMG315.png,MAP208.png,SND316.wav,IMG316.png,MAP202.png,SND202.wav,IMG202.png,MAP210.png,SND240.wav,IMG240.png,MAP210.png,SND240.wav,IMG240.png,4216,0,3500,20400,34800,C207.png +squawk(スクォーク),MAP100.png,SND100.wav,heart.png,MAP101.png,SND101.wav,heart.png,MAP200.png,SND320.wav,IMG320.png,MAP208.png,SND321.wav,IMG321.png,MAP202.png,SND202.wav,IMG202.png,MAP213.png,SND250.wav,IMG250.png,MAP213.png,SND250.wav,IMG250.png,3026,0,2800,18600,38890,C208.png +pleural friction rub(胸膜摩擦音),MAP100.png,SND100.wav,heart.png,MAP101.png,SND101.wav,heart.png,MAP200.png,SND320.wav,IMG320.png,MAP208.png,SND321.wav,IMG321.png,MAP202.png,SND202.wav,IMG202.png,MAP210.png,SND260.wav,IMG260.png,MAP216.png,SND203.wav,IMG203.png,3270,0,500,18000,32000,C209.png +正常呼吸音(心音付き),MAP100.png,SND100.wav,heart.png,MAP101.png,SND101.wav,heart.png,MAP200.png,SND200.wav,IMG200.png,MAP201.png,SND201.wav,IMG201.png,MAP202.png,SND202.wav,IMG202.png,MAP203.png,SND203.wav,IMG203.png,MAP203.png,SND203.wav,IMG203.png,2797,0,3000,14500,31000,C999.png +正常心音,MAP100.png,SND100.wav,heart.png,MAP101.png,SND101.wav,heart.png,MAP200.png,SND200.wav,breath.png,MAP201.png,SND201.wav,breath.png,MAP202.png,SND202.wav,breath.png,MAP203.png,SND203.wav,breath.png,MAP203.png,SND203.wav,IMG203.png,798,1,3000,14500,31000,C999.png +大動脈弁狭窄症,MAP105.png,SND130.wav,IMG130.png,none,none,none,MAP200.png,SND200.wav,breath.png,MAP201.png,SND201.wav,breath.png,MAP202.png,SND202.wav,breath.png,MAP203.png,SND203.wav,breath.png,MAP203.png,SND203.wav,IMG203.png,798,1,3000,14500,31000,C102.png +閉塞性肥大型心筋症,MAP106.png,SND171.wav,IMG171.png,none,none,none,MAP200.png,SND200.wav,breath.png,MAP201.png,SND201.wav,breath.png,MAP202.png,SND202.wav,breath.png,MAP203.png,SND203.wav,breath.png,MAP203.png,SND203.wav,IMG203.png,801,1,3000,14500,31000,C108.png +心室中隔欠損症,MAP106.png,SND173.wav,IMG173.png,none,none,none,MAP200.png,SND200.wav,breath.png,MAP201.png,SND201.wav,breath.png,MAP202.png,SND202.wav,breath.png,MAP203.png,SND203.wav,breath.png,MAP203.png,SND203.wav,IMG203.png,699,1,3000,14500,31000,C110.png +僧帽弁逆流症,MAP104.png,SND121.wav,IMG121.png,none,none,none,MAP200.png,SND200.wav,breath.png,MAP201.png,SND201.wav,breath.png,MAP202.png,SND202.wav,breath.png,MAP203.png,SND203.wav,breath.png,MAP203.png,SND203.wav,IMG203.png,801,1,3000,14500,31000,C105.png +三尖弁逆流症,MAP106.png,SND140.wav,IMG140.png,none,none,none,MAP200.png,SND200.wav,breath.png,MAP201.png,SND201.wav,breath.png,MAP202.png,SND202.wav,breath.png,MAP203.png,SND203.wav,breath.png,MAP203.png,SND203.wav,IMG203.png,1566,1,3000,14500,31000,C107.png +心房中隔欠損症,MAP106.png,SND170.wav,IMG170.png,none,none,none,MAP200.png,SND200.wav,breath.png,MAP201.png,SND201.wav,breath.png,MAP202.png,SND202.wav,breath.png,MAP203.png,SND203.wav,breath.png,MAP203.png,SND203.wav,IMG203.png,712,1,3000,14500,31000,C109.png +大動脈弁逆流症,MAP105.png,SND131.wav,IMG131.png,none,none,none,MAP200.png,SND200.wav,breath.png,MAP201.png,SND201.wav,breath.png,MAP202.png,SND202.wav,breath.png,MAP203.png,SND203.wav,breath.png,MAP203.png,SND203.wav,IMG203.png,793,1,3000,14500,31000,C103.png +肺動脈弁逆流症,MAP150.png,SND150.wav,IMG150.png,none,none,none,MAP200.png,SND200.wav,breath.png,MAP201.png,SND201.wav,breath.png,MAP202.png,SND202.wav,breath.png,MAP203.png,SND203.wav,breath.png,MAP203.png,SND203.wav,IMG203.png,778,1,3000,14500,31000,C999.png +僧房弁狭窄症,MAP104.png,SND120.wav,IMG120.png,none,none,none,MAP200.png,SND200.wav,breath.png,MAP201.png,SND201.wav,breath.png,MAP202.png,SND202.wav,breath.png,MAP203.png,SND203.wav,breath.png,MAP203.png,SND203.wav,IMG203.png,760,1,3000,14500,31000,C104.png +動脈管開存症,MAP106.png,SND172.wav,IMG172.png,none,none,none,MAP200.png,SND200.wav,breath.png,MAP201.png,SND201.wav,breath.png,MAP202.png,SND202.wav,breath.png,MAP203.png,SND203.wav,breath.png,MAP203.png,SND203.wav,IMG203.png,799,1,3000,14500,31000,C111.png +Ⅲ音,MAP102.png,SND110.wav,IMG110.png,none,none,none,MAP200.png,SND200.wav,breath.png,MAP201.png,SND201.wav,breath.png,MAP202.png,SND202.wav,breath.png,MAP203.png,SND203.wav,breath.png,MAP203.png,SND203.wav,IMG203.png,1013,1,3000,14500,31000,C101.png +Ⅳ音,MAP103.png,SND111.wav,IMG111.png,none,none,none,MAP200.png,SND200.wav,breath.png,MAP201.png,SND201.wav,breath.png,MAP202.png,SND202.wav,breath.png,MAP203.png,SND203.wav,breath.png,MAP203.png,SND203.wav,IMG203.png,900,1,3000,14500,31000,C101.png +心膜摩擦音,MAP106.png,SND160.wav,IMG160.png,none,none,none,MAP200.png,SND200.wav,breath.png,MAP201.png,SND201.wav,breath.png,MAP202.png,SND202.wav,breath.png,MAP203.png,SND203.wav,breath.png,MAP203.png,SND203.wav,IMG203.png,985,1,3000,14500,31000,C999.png +心膜ノック音,MAP106.png,SND161.wav,IMG161.png,none,none,none,MAP200.png,SND200.wav,breath.png,MAP201.png,SND201.wav,breath.png,MAP202.png,SND202.wav,breath.png,MAP203.png,SND203.wav,breath.png,MAP203.png,SND203.wav,IMG203.png,644,1,3000,14500,31000,C999.png +僧房弁解放音,MAP104.png,SND123.wav,IMG123.png,none,none,none,MAP200.png,SND200.wav,breath.png,MAP201.png,SND201.wav,breath.png,MAP202.png,SND202.wav,breath.png,MAP203.png,SND203.wav,breath.png,MAP203.png,SND203.wav,IMG203.png,928,1,3000,14500,31000,C999.png +収縮中期クリック音,MAP106.png,SND174.wav,IMG174.png,none,none,none,MAP200.png,SND200.wav,breath.png,MAP201.png,SND201.wav,breath.png,MAP202.png,SND202.wav,breath.png,MAP203.png,SND203.wav,breath.png,MAP203.png,SND203.wav,IMG203.png,1089,1,3000,14500,31000,C999.png +三尖弁狭窄症,MAP106.png,SND141.wav,IMG141.png,none,none,none,MAP200.png,SND200.wav,breath.png,MAP201.png,SND201.wav,breath.png,MAP202.png,SND202.wav,breath.png,MAP203.png,SND203.wav,breath.png,MAP203.png,SND203.wav,IMG203.png,1566,1,3000,14500,31000,C999.png +僧房弁逸脱症,MAP104.png,SND122.wav,IMG122.png,none,none,none,MAP200.png,SND200.wav,breath.png,MAP201.png,SND201.wav,breath.png,MAP202.png,SND202.wav,breath.png,MAP203.png,SND203.wav,breath.png,MAP203.png,SND203.wav,IMG203.png,800,1,3000,14500,31000,C106.png +OSCE,MAP100.png,SND100.wav,heart.png,MAP101.png,SND101.wav,heart.png,MAP200.png,SND200.wav,IMG200.png,MAP201.png,SND202.wav,IMG201.png,MAP202.png,SND203.wav,IMG202.png,MAP403.png,SND203.wav,IMG203.png,MAP404.png,SND203.wav,IMG203.png,2797,0,3000,14500,31000,C999.png diff --git a/program/program.cs b/program/program.cs index 58b3683..7e21433 100644 --- a/program/program.cs +++ b/program/program.cs @@ -6,6 +6,14 @@ [STAThread] static void Main(string[] args) { + Console.WriteLine("argv = [" + string.Join(" | ", args) + "]"); + + // --- flags first, before any UI construction --- + AppMode.Legacy = Array.IndexOf(args, "--legacy") >= 0; + // ... existing --debug handling stays here too ... + Console.WriteLine("AppMode.Legacy = " + AppMode.Legacy + + " cases=" + AppMode.CasesCsv); + Application.Init(); var app = new MainWindow(); @@ -20,4 +28,4 @@ Application.Run(); } -} \ No newline at end of file +}